We had a test last Sunday on Operators
Where we got to know that instanceof cannot be assigned
to Boolean values.
But this code snippet works fine when you compile in Java 1.5
class instanceofdemo
{ public static void main(String[] args)
{ Parent obj2 = new Child();
boolean a=obj1 instanceof Parent;
System.out.println("obj1 instanceof Parent: "+a);
}}
class Parent{}
class Child extends Parent implements MyInterface{}
interface MyInterface{}
0 comments:
Post a Comment