5. Program
//Find what it gives Compiletion Error / Compiletion Successfully / Output ?
class E { int i, j; E(int i,int j) { this.i = i; this.j = j; } } class Manager5 { public static void main (String[] args) { E e1 = new E(20,10); E e2 = new E(20,10); System.out.println(e1); System.out.println(e2); } }
6. Program
//Find what it gives Compiletion Error / Compiletion Successfully / Output ?
class F { int i; public String toString() // overriding of toString method { return"i = " + i; } } class Manager6 { public static void main (String[] args) { F f1 = new F(); f1.i = 10; System.out.println(f1); } }
7. Program
//Find what it gives Compiletion Error / Compiletion Successfully / Output ?
class G { int i, j; public String toString() // overriding of toString method { return"i = " + i + ", j = " + j ; } } class Manager7 { public static void main (String[] args) { G g1 = new G(); g1.i = 10; g1.j = 10; System.out.println(g1); } }
8. Program
//Find what it gives Compiletion Error / Compiletion Successfully / Output ?
class H { int x; public String toString() { return"x = " + x ; } } class I { int y; H h1; public String toString() { return h1 + ", y = " + y; } } class Manager8 { public static void main (String[] args) { H h1 = new H(); h1.x = 10; I i1 = new I(); i1.y= 10; i1.h1 = h1; System.out.println(h1); System.out.println(i1); } }