-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path_19_Runtime_Polymorphism.java
More file actions
58 lines (56 loc) · 1.61 KB
/
Copy path_19_Runtime_Polymorphism.java
File metadata and controls
58 lines (56 loc) · 1.61 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
//exists at the time of execution of program.
// ex - methord overriding.
// whenever we writing methord in super and sub classes in such a way that methord name and parameter must be same called methord overriding.
// rules of methord overriding -
// methord No(compiletion error) yes(overriden or not) No(Call super class methoed) Yes(call sub class methord)
//public class _19_Runtime_Polymorphism {
// void draw(){
// System.out.println("Can't say shape Type");
// }
//}
//class square extends _19_Runtime_Polymorphism{
// @Override
// void draw(){
// System.out.println("square shape"); // output
// }
//}
//class Deo{
// public static void main(String[] args) {
// _19_Runtime_Polymorphism r = new square();
// r.draw();
// }
//}
//public class _19_Runtime_Polymorphism {
// void draw(){
// System.out.println("Can't say shape Type"); // output
// }
//}
//class square extends _19_Runtime_Polymorphism{
// void draw(){
// System.out.println("square shape");
// }
//}
//class Deo{
// public static void main(String[] args) {
// _19_Runtime_Polymorphism r = new square();
// r.draw();
// }
//}
public class _19_Runtime_Polymorphism {
void draw(){
System.out.println("Can't say shape Type");
}
}
class square extends _19_Runtime_Polymorphism{
@Override
void draw(){
super.draw();
System.out.println("square shape");
}
}
class Deo{
public static void main(String[] args) {
_19_Runtime_Polymorphism r = new square();
r.draw();
}
}