| Author |
Inheritance-1
|
Ritu Kapoor
Ranch Hand
Joined: Oct 03, 2004
Posts: 101
|
|
Code: --------------------------------------------------- class AA { } class BB extends AA { } class Class24 { public static void main(String arg[]) { AA a = null; BB b = (BB) a; System.out.println(b instanceof AA); System.out.println(b instanceof BB); } } -------------------------------------------------------------- Output: false,false Query: Why the output is false for the above code. Please give explanation for that.
|
 |
Seb Mathe
Ranch Hand
Joined: Sep 28, 2005
Posts: 225
|
|
|
Regarding the specs for the instanceof operaor : if the left operand is null, result is always false.
|
Regards,<br />Seb<br /> <br />SCJP 1.4
|
 |
 |
|
|
subject: Inheritance-1
|
|
|