-
Notifications
You must be signed in to change notification settings - Fork 4
/
polymorphism_in_inheritance.java
62 lines (58 loc) · 1.3 KB
/
polymorphism_in_inheritance.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
interface MyCamera //Interface 1
{
void takeSnap();
void recordVideo();
private void greet()
{
System.out.println("Good Morning");
}
default void record4kVideo()
{
greet();
System.out.println("Recording in 4k...");
}
}
interface MyWifi //Interface 2
{
String [] getNetworks();
void connectToNetworks(String network);
}
class MyCellPhone //Class 1
{
void callNumber(int phoneNumber)
{
System.out.println("Calling "+phoneNumber);
}
void pickCall(){
System.out.println("Connecting...");
}
}
class MySmartPhone extends MyCellPhone implements MyWifi,MyCamera
{
public void takeSnap()
{
System.out.println("Taking Snap...");
}
public void recordVideo()
{
System.out.println("Recording Video...");
}
public String [] getNetworks()
{
System.out.println("Getting List Of Networks...");
String [] networkList={"Samar","Harry","Coding"};
return networkList;
}
public void connectToNetworks(String networks)
{
System.out.println("Connecting to "+ networks);
}
}
public class polymorphism_in_inheritance
{
public static void main(String args[])
{
MyCellPhone cam=new MySmartPhone();
cam.callNumber(637090933);
}
}