Id: 9585; Nick: XtraCt; Timestamp: 2008-04-21 13:38:10; Pasted as: Java
Description: n/a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
class Parent{}
class Child extends Parent implements MyInterface{}
interface MyInterface{}
 
class Main {
public static void main(String[] args){
    Parent obj1 = new Parent();
    Parent obj2 = new Child();
 
    System.out.println("obj1 instanceof Parent: " + (obj1 instanceof Parent));
    System.out.println("obj1 instanceof Child: " + (obj1 instanceof Child));
    System.out.println("obj1 instanceof MyInterface: " + (obj1 instanceof MyInterface));
    System.out.println("obj2 instanceof Parent: " + (obj2 instanceof Parent));
    System.out.println("obj2 instanceof Child: " + (obj2 instanceof Child));
    System.out.println("obj2 instanceof MyInterface: " + (obj2 instanceof MyInterface));
 
     }
}
Options: New, Download,
;
Copyright © 2006 by Zyberdog - Some rights reserved. (Browse/Disclaimer/Stats/About) - Highlighted with GeSHi