31. Program
//Find what it gives Compiletion Error / Compiletion Successfully / Output ?
class I implements Cloneable { int i; public static void main(String[] args) throws CloneNotSupportedException { I i1 = new I(); i1.i = 10; I i2 = (I)i1.clone(); System.out.println(i2.i); } }
32. Program
//Find what it gives Compiletion Error / Compiletion Successfully / Output ?
class J implements Cloneable { int i; public static void main(String[] args) throws CloneNotSupportedException { J j1 = new J(); j1.i = 10; J j2 = (J)j1.clone(); System.out.println(j2.i); System.out.println(j1); System.out.println(j2); System.out.println(j1==j2); } }
33. Program
//Find what it gives Compiletion Error / Compiletion Successfully / Output ?
class K implements Cloneable { int i; K() { System.out.println("K()"); } public static void main(String[] args) throws CloneNotSupportedException { K k1 = new K(); k1.i = 10; System.out.println("....."); K k2 = (K)k1.clone(); System.out.println(k2.i); } }
34. Program
//Find what it gives Compiletion Error / Compiletion Successfully / Output ?
//getClass method Used class L { } class Manager10 { public static void main(String[] args) { L l1 = new L(); L l2 = new L(); Class c1 = l1.getClass(); Class c2 = l2.getClass(); System.out.println(c1 == c2); System.out.println(l1 == l2); } }