I was reading following question from link
http://www.jchq.net/certkey/0501certkey.htm
>>>instanceof tests against a class name and not against an object reference for a class
did not understand it clearly.
import java.awt.*;
public class InOfComp {
public static void main(
String argv[]){
}//End of main
public void mymethod(Component c){
if( c instanceof Button){
Button bc = (Button) c;
bc.setLabel("Hello");
}
else
if (c instanceof Label){
Label lc = (Label) c;
lc.setText("Hello");
}
}//End of mymethod
}
I could not see output on console. How to run and see the output to understand instanceof concept relating to child etc classes.