-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathabstractkey.java
More file actions
58 lines (38 loc) · 880 Bytes
/
Copy pathabstractkey.java
File metadata and controls
58 lines (38 loc) · 880 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// abstract method is defined in abstract class
abstract class car{
// public void drive()
// {
// }
// declare drive() method
public abstract void drive();
public abstract void fly();
public void playmusic()
{
System.out.println("playing music...");
}
}
abstract class alto extends car
{
public void drive()
{
System.out.println("driving alto...");
}
}
class updatedalto extends alto
{
public void fly()
{
System.out.println("flying...");
}
}
public class abstractkey {
public static void main(String[] args) {
// cannot create abstract class object
// car obj = new car();
//using alto reference obj of car type
car obj = new updatedalto();
obj.drive();
obj.playmusic();
obj.fly();
}
}