-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPolymorphismExample.java
More file actions
65 lines (55 loc) · 1.14 KB
/
PolymorphismExample.java
File metadata and controls
65 lines (55 loc) · 1.14 KB
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
59
60
61
62
63
64
65
//Program to create a class telephone with ( ) , lift ( ) and disconnected ( ) methods as abstract methods create another class smart telephone and demonstrate polymorphism
interface telephone2
{
void pickCall();
void recieveCall();
}
interface phone2
{
void call();
void with();
void lift();
void disconnected();
}
class CellPhone
{
void recording_audio()
{
System.out.print("\nHello hello babya baye ..");
}
}
class Smartphone extends CellPhone implements telephone2, phone2
{
public void call()
{
System.out.print("\nHello is it ....care");
}
public void with()
{
System.out.println("\nI am on a call with my friend.");
}
public void lift()
{
System.out.print("\nHello your lift is good now.");
}
public void disconnected()
{
System.out.print("\nCall is disconnected.");
}
public void pickCall()
{
System.out.print("\nHello, It's Hello");
}
public void recieveCall()
{
System.out.println("Bye ...");
}
}
class PolymorphismExample {
public static void main(String args[])
{
telephone2 tl = new Smartphone();
tl.pickCall();
tl.recieveCall();
}
}