hi guys
please answer this ques and explain
class Tree { }
class Pine extends Tree { }
class Oak extends Tree { }
public class Forest {
public static void main(
String [] args) {
Tree tree = new Pine ();
if (tree instanceof Pine) System.out.println("Pine");
if (tree instanceof Tree) System.out.println("Tree");
if (tree instanceof Oak) System.out.println("Oak");
else System.out.println("Oops");
}
}
What will be the output?
x a) Pine
x b) Tree
c) Forest
x d) Oops
e) (nothing printed)