

Java.lang Class - Programming
Q1: 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 ');
}
}
A Pine
B Tree
C Forest
D Oops
ANS:A - Pine The program prints "Pine". |


For help Students Orientation
Mcqs Questions
One stop destination for examination, preparation, recruitment, and more. Specially designed online test to solve all your preparation worries. Go wherever you want to and practice whenever you want, using the online test platform.