Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

using instanceof keyword?

807601Apr 12 2008 — edited Apr 12 2008
Hello

what is the use of this keyword in inheritance? is it to access methods in child class I write it like this:
Parent p = new Child();
if (p instanceof Child){
  
    Child c = (Child) p;
  
}
now when I write p.getName(); which the method is defined in the child class only not in the parent class. it would return the value name of the child class?
I couldn't understand this tutorial I read it in the tutorial page about the Bike.

thanks
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 10 2008
Added on Apr 12 2008
2 comments
114 views