Basic single level inheritance
1) Resolve the compilation error :
package com.gs.ilp.corejava.Constructor;
public class ParentWithCon {
String mem1;
String mem2;
public ParentWithCon(String mem1) {
this.mem1 = mem1;
}
public ParentWithCon(String mem1, String mem2) {
this.mem1 = mem1;
this.mem2 = mem2;
}
}
class ChildWithCon extends ParentWithCon {
public ChildWithCon(String mem1) {
super(mem1);
}
public ChildWithCon(String mem1, String mem2) {
super(mem1, mem2);
}
}
package com.gs.ilp.corejava.Constructor;
class AA {
AA() {
System.out.println("AA");
}
AA(int i) {
this();
System.out.println("AA " + i);
}
}
class BB extends AA {
BB() {
System.out.println("BB");
}
BB(int i) {
this();
System.out.println("BB " + i);
}
}
package com.gs.ilp.corejava.Constructor;
public class Problem2 {
public static void main(String[] args) {
new BB(4);
}
}
package com.gs.ilp.corejava.Constructor;
class AA {
AA(int i) {
this();
System.out.println("AA " + i);
}
}
class BB extends AA {
BB() {
System.out.println("BB");
}
BB(int i) {
this();
System.out.println("BB " + i);
}
}
package com.gs.ilp.corejava.Constructor;
public class AAA {
Object m1() {
return null;
}
}
class BBB extends AAA {
String m1() {
return null;
}
}
package com.gs.ilp.corejava.Constructor;
public class AAA {
void m1() {
}
}
class BBB extends AAA {
int m1() {
return 0;
}
}
package com.gs.ilp.corejava.Constructor;
class AAA {
Object m1() {
System.out.println("AAA m1");
return null;
}
}
class BBB extends AAA {
String m1() {
System.out.println("BBB m1");
return null;
}
}
public class Test2 {
public static void main(String[] args) {
AAA aaa = new AAA();
aaa.m1();
BBB bbb = new BBB();
bbb.m1();
AAA aba = new BBB();
aba.m1();
}
}
package com.gs.ilp.corejava.Constructor;
class Animal {
}
class Dog {
}
class Parent {
Animal m1() {
return null;
}
}
class Child {
Dog m1() {
return null;
}
}
public class Test3 {
}