package dk.itu.oop.testexamf2004; public class Test1 { public static void main(String[] args){ System.out.println( (new Test1a(3)).toString() ); new Test1b2(4); new Test1c(); } } class Test1a { private int i; private int j = 8; private int k; { int i = j; } public Test1a(int k){ this.k = k; } public String toString(){ return "i: " + i + " j: " + j + " k: " + k ; } } class Test1b1 { protected int i = 9; int j; private int k; { k = 8; } public void printMe(){ System.out.println("i:"+i+" j:"+j+" k:"+k); } public Test1b1(int j){ printMe(); this.j = j; } } class Test1b2 extends Test1b1 { int j; // extra code here protected static int i; public Test1b2(){ this(9); } public Test1b2(String s){ super(Integer.parseInt(s)); } public Test1b2(int value){ super(value); i = 6; j = 10; // extra code here //k = 13; printMe(); } } class A {int i;} class B extends A {int j; } class Test1c { public Test1c(){ A a = new B(); B b = new B(); A[] as = new B[10]; B[] bs = new B[10]; b = (B)a; // code 2 bs = (B[])as; // code 4 //as = bs; //as[1] = new A(); } }