aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Inheritance-1 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Inheritance-1" Watch "Inheritance-1" New topic
Author

Inheritance-1

Ritu Kapoor
Ranch Hand

Joined: Oct 03, 2004
Posts: 102
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Inheritance-1
 
Similar Threads
Operators and Precedence
instanceof operator
InstanceOf Doubt.
Doubt on instanceof operator
instanceof Comparison