FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
Java-Hackerrank-Solutions/Java/OOP/Inheritance2.java at main · Manush54/Java-Hackerrank-Solutions · GitHub
Manush54
/
Java-Hackerrank-Solutions
Public
Notifications
You must be signed in to change notification settings
Fork
9
Star
21
Code
Issues
0
Pull requests
1
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
Java-Hackerrank-Solutions
/
Java
/
OOP
/
Inheritance2.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
20 lines (17 loc) · 637 Bytes
Breadcrumbs
Java-Hackerrank-Solutions
/
Java
/
OOP
/
Inheritance2.java
Copy path
File metadata and controls
20 lines (17 loc) · 637 Bytes
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
//Write your code here
class
Arithmetic
{
int
add
(
int
a
,
int
b
){
return
a
+
b
;
}
}
class
Adder
extends
Arithmetic
{}
public
class
Inheritance2
{
public
static
void
main
(
String
[]
args
){
// Create a new Adder object
Adder
a
=
new
Adder
();
// Print the name of the superclass on a new line
System
.
out
.
println
(
"My superclass is: "
+
a
.
getClass
().
getSuperclass
().
getName
());
// Print the result of 3 calls to Adder's `add(int,int)` method as 3 space-separated integers:
System
.
out
.
print
(
a
.
add
(
10
,
32
) +
" "
+
a
.
add
(
10
,
3
) +
" "
+
a
.
add
(
10
,
10
) +
"
\n
"
);
}
}
Back
|
FazBrowse Home
|
New Git URL