-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path_15_Super_keyword.java
More file actions
72 lines (62 loc) · 1.68 KB
/
Copy path_15_Super_keyword.java
File metadata and controls
72 lines (62 loc) · 1.68 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
66
67
68
69
70
71
72
// refers to the objects of super class.
// it is use when you want to call super class veriable, methord, constructor through sub class object.
// super and sub class variable and methord both are same then it is use.
// to aviod the confusion between super and sub class variables and methords that have same name we use super.
//super calls veriable, methord, constructor.
// variable
//public class _15_Super_keyword {
// int a=10;
//}
//class fifteen extends _15_Super_keyword{
// int a=20;
// void show(){
// System.out.println(a);
// System.out.println(super.a);
// }
//}
//
//class est{
// public static void main(String[] args) {
// fifteen r = new fifteen();
// r.show();
// }
//}
// Methords
//public class _15_Super_keyword {
// void show()
// {
// System.out.println("Hell");
// }
//}
//class fifteen extends _15_Super_keyword{
// void show(){
// super.show();
// System.out.println("Hello");
// }
//}
//
//class est{
// public static void main(String[] args) {
// fifteen r = new fifteen();
// r.show();
// }
//}
// Constructor
public class _15_Super_keyword {
_15_Super_keyword(int a)
{
System.out.println("Hell");
}
}
class fifteen extends _15_Super_keyword{
fifteen(){
// super(); compiler will call automatically. when you not use super class. when it is difault constructor.
super(100); // parametrised constructor compelsory to right.
System.out.println("Hello");
}
}
class est{
public static void main(String[] args) {
fifteen r = new fifteen();
}
}