Multiple choice

What will be the output of the program? class Tree { } class Pine extends Tree { } class Oak extends Tree { } public class Forest1 { public static void main (String [] args) { Tree tree = new Pine(); if( tree instanceof Pine ) System.out.println ("Pine"); else if( tree instanceof Tree ) System.out.println ("Tree"); else if( tree instanceof Oak ) System.out.println ( "Oak" ); else System.out.println ("Oops "); } }

  1. Pine

  2. Tree

  3. Forest

  4. Oops

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

The program prints "Pine".