FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
java-programs/Derived_Class/StudentResult.java at main · IntScription/java-programs · GitHub
IntScription
/
java-programs
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
1
Code
Issues
0
Pull requests
0
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-programs
/
Derived_Class
/
StudentResult.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
89 lines (68 loc) · 2.02 KB
Breadcrumbs
java-programs
/
Derived_Class
/
StudentResult.java
Copy path
File metadata and controls
89 lines (68 loc) · 2.02 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/*
* Design a class called Student having data members like student name and roll
* number and method called show to display the name and roll number. Derive a
* class called Test from student class having three subjects marks as a data
* members and method named show_marks to display the marks. Create an interface
* called Sports contains constant sports marks and method show_sportswt. Derive
* a class Result from Test class and implement the interface Sports. Calculate
* total marks by considering sports marks. Then display the total in Result
* class.
*/
package
Derived_Class
;
import
java
.
util
.
Scanner
;
class
Student
{
String
name
;
int
rollno
;
Student
(
String
name
,
int
rno
) {
this
.
name
=
name
;
rollno
=
rno
;
}
void
show
() {
System
.
out
.
println
(
"Name: "
+
name
+
"
\n
Roll Number: "
+
rollno
);
}
}
class
Test
extends
Student
{
int
sub1
,
sub2
,
sub3
;
Test
(
int
sub1
,
int
sub2
,
int
sub3
,
String
name
,
int
rno
) {
super
(
name
,
rno
);
this
.
sub1
=
sub1
;
this
.
sub2
=
sub2
;
this
.
sub3
=
sub3
;
}
void
show_marks
() {
super
.
show
();
System
.
out
.
println
(
"Subject 1: "
+
sub1
+
"
\n
Subject 2: "
+
sub2
+
"
\n
Subject 3: "
+
sub3
);
}
}
interface
Sports
{
final
int
sport_mark
=
40
;
void
show_sportswt
();
}
class
Result
extends
Test
implements
Sports
{
int
total
=
sub1
+
sub2
+
sub3
+
sport_mark
;
public
void
show_sportswt
() {
System
.
out
.
println
(
"Sports marks: "
+
sport_mark
);
}
Result
(
String
name
,
int
rollno
,
int
sub1
,
int
sub2
,
int
sub3
) {
super
(
sub1
,
sub2
,
sub3
,
name
,
rollno
);
}
void
display
() {
super
.
show_marks
();
System
.
out
.
println
(
"Total Marks: "
+
total
);
}
}
public
class
StudentResult
{
public
static
void
main
(
String
[]
args
){
Scanner
s
=
new
Scanner
(
System
.
in
);
System
.
out
.
println
(
"Enter name, roll number and marks in 3 subjects:"
);
String
name
=
s
.
nextLine
();
int
rno
=
s
.
nextInt
();
int
sub1
=
s
.
nextInt
();
int
sub2
=
s
.
nextInt
();
int
sub3
=
s
.
nextInt
();
Result
res
=
new
Result
(
name
,
rno
,
sub1
,
sub2
,
sub3
);
res
.
display
();
res
.
show_sportswt
();
s
.
close
();
}
}
Back
|
FazBrowse Home
|
New Git URL