testing inheritance and abstract classes in java
This commit is contained in:
+1
-1
@@ -43,7 +43,7 @@ public class Main {
|
||||
|
||||
// List<Integer> nombres = Arrays.asList(1721, 979, 366, 299, 675, 1456);
|
||||
// calculProduit(nombres);
|
||||
//
|
||||
|
||||
countingSheeps(0);
|
||||
|
||||
}
|
||||
|
||||
+34
-4
@@ -1,11 +1,41 @@
|
||||
import java.util.List;
|
||||
import java.util.Arrays;
|
||||
|
||||
// import java.util.LinkedList;
|
||||
// import java.util.Queue;
|
||||
|
||||
public class Test {
|
||||
public static void main(String[] args) {
|
||||
System.out.println("Hello");
|
||||
Child child = new Child();
|
||||
child.hello();
|
||||
child.hi();
|
||||
child.sup();
|
||||
System.out.println(child.n);
|
||||
}
|
||||
}
|
||||
|
||||
abstract public class Mother {
|
||||
public int n;
|
||||
public Mother() {
|
||||
}
|
||||
public Mother(int n) {
|
||||
this.n = n;
|
||||
}
|
||||
abstract public void hello();
|
||||
public void hi() {
|
||||
System.out.println("hi");
|
||||
}
|
||||
}
|
||||
|
||||
public class Child extends Mother {
|
||||
public Child() {
|
||||
}
|
||||
public Child(int n) {
|
||||
super(n);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hello() {
|
||||
System.out.println("hello");
|
||||
}
|
||||
public void sup() {
|
||||
System.out.println("sup");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user