FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
Java-Programs-1/Inheritance/SingleLevel.java at master · Scarlet-Coder/Java-Programs-1 · GitHub
Scarlet-Coder
/
Java-Programs-1
Public
forked from
divScorp/Java-Programs
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
Java-Programs-1
/
Inheritance
/
SingleLevel.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
62 lines (50 loc) · 1.21 KB
Breadcrumbs
Java-Programs-1
/
Inheritance
/
SingleLevel.java
Copy path
File metadata and controls
62 lines (50 loc) · 1.21 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
package
Inheritance
;
class
A
{
private
int
i
=
12
;
protected
int
j
=
13
;
public
int
k
=
14
;
int
m
=
3
;
A
() {
System
.
out
.
println
(
"I'm Constructor from class A."
);
}
private
void
m1
() {
System
.
out
.
println
(
"Private method of class A "
+
i
);
}
protected
void
m2
() {
System
.
out
.
println
(
"Protected method of class A "
+
j
);
m1
();
}
public
void
m3
() {
System
.
out
.
println
(
"Public method of class A "
+
k
);
}
void
m4
() {
System
.
out
.
println
(
"Package method of class A"
+
i
+
" "
+
m
);
}
}
class
B
extends
A
{
B
() {
System
.
out
.
println
(
"I'm Constructor from class B."
);
}
public
void
m5
() {
// System.out.println(i); // private variables not accessible in
// sub-class
System
.
out
.
println
(
" Method from class B. "
);
System
.
out
.
println
(
"Protected j= "
+
j
);
System
.
out
.
println
(
"public k= "
+
k
);
System
.
out
.
println
(
"Package m= "
+
m
);
// m1(); // Private method is not accessible in sub-class
m2
();
m3
();
m4
();
}
}
public
class
SingleLevel
{
public
static
void
main
(
String
[]
args
) {
B
b
=
new
B
();
System
.
out
.
println
(
"----------------------------------"
);
System
.
out
.
println
(
" From Main method. "
);
b
.
m5
();
b
.
m4
();
System
.
out
.
println
(
"----------------------------------"
);
}
}
Back
|
FazBrowse Home
|
New Git URL