-
Notifications
You must be signed in to change notification settings - Fork 39
Expand file tree
/
Copy pathquiz2.java
More file actions
37 lines (33 loc) · 804 Bytes
/
quiz2.java
File metadata and controls
37 lines (33 loc) · 804 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
______ A { // abstract class
private int x;
public abstract void f();
}
______ B ______ A { // abstract class B extends A {
private int x;
public B() { x = 99; }
}
______ C { //interface C
public void f();
public void g();
}
______ D _____ C { // class D implements C
public void f() {}
public void g() {}
}
public class test {
public static void main(String[]args) {
A a1;
A a2 = new A(); // illegal: cannot instantiate abstract class
B b1 = new B();
B b2 = new B(2);
C c1 = new C(); // ILLEGAL: cannot instantiate interface
// new class here test$1
C c2 = new C() { // ILLEGAL: cannot instantiate abstract class
public void f() {}
};
D d1 = new D();
D d2 = new D() { // test$2
public void g() { System.out.println("something else"); }
}
}
}