Which of the given statements are correct about the following code?
//Filename: Main.java class Main{ // w ww . j av a2 s.co m public static void main (String [] args){ A a = new A (); B b = new B (); }; } class A implements T1, T2{} class B extends A implements T1{} interface T1 { } interface T2 { }
Select 4 options
Correct Options are : A B C D
It will return true because B extends A and 'b' is referring to an object of class B.
Since A implements both T1 and T2, 1 and 2 are correct.
b instanceof A will return true as B is a subclass of A. Note that it is 'A' and not 'a'.
( b instanceof a ) will not compile.