-
-
Notifications
You must be signed in to change notification settings - Fork 55
/
Copy pathclientAbstract.java
47 lines (33 loc) Β· 1003 Bytes
/
clientAbstract.java
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
38
39
40
41
42
43
44
45
46
47
package Lecture16;
public class clientAbstract {
public static void main(String[] args) {
// not allowed
// parentAbstract obj = new parentAbstract(); // Cannot instantiate the type parentAbstract
// since parentAbstract class is abstract, you cannot make object of
// that class it can only be inherited
// not allowed
// childAbstract obj = new parentAbstract(); // Cannot instantiate the type parentAbstract
parentAbstract obj = new childAbstract();
obj.fun();
obj.fun1();
obj.fun2();
// not allowed as fun3() presence is checked in parentAbstract by compiler
// obj.fun3(); // The method fun3() is undefined for the type parentAbstract
System.out.println("=========================");
childAbstract obj2 = new childAbstract();
obj2.fun();
obj2.fun1();
obj2.fun2();
obj2.fun3();
}
}
/* output:
Inside child fun
Inside child fun1
Inside parent fun2
=========================
Inside child fun
Inside child fun1
Inside parent fun2
Inside child fun2
*/