abstract class A{
abstract int nNum();
}
class A1 extends A{
int nNum(){
return 1;
}
}
class A2 extends A{
int nNum(){
return 2;
}
}
public class Test_Abst {
public static void main(String[] args) {
System.out.println("Start");
//抽象クラス
System.out.println("------------------------");
A Obj1 = new A1();
A Obj2 = new A2();
System.out.println("Obj1.nNum -> " + Obj1.nNum());
System.out.println("Obj2.nNum -> " + Obj2.nNum());
System.out.println("");
//Class クラス
Class Cls1 = Obj1.getClass();
Class Cls2 = Obj2.getClass();
System.out.println("Obj1 -> " + Obj1.toString());
System.out.println("Cls1 -> " + Cls1);
System.out.println("Cls1Super -> " + Cls1.getSuperclass().getName());
System.out.println("Obj2 -> " + Obj2.toString());
System.out.println("Cls2 -> " + Cls2);
System.out.println("Cls2Super -> " + Cls2.getSuperclass().getName());
//
System.out.println("------------------------");
System.out.println("End");
}
}
|