-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMultilevelInheritance.java
More file actions
60 lines (58 loc) · 1.1 KB
/
Copy pathMultilevelInheritance.java
File metadata and controls
60 lines (58 loc) · 1.1 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
import java.util.*;
class Student
{
int rollno;
String name;
void get_stud_info()
{
try (Scanner sc = new Scanner(System.in)) {
System.out.println("Enter Student Roll NO:");
rollno=sc.nextInt();
System.out.println("Enter Student Name:");
name=sc.next();
}
}
void disp_stud_info()
{
System.out.println("Roll No:"+rollno);
System.out.println("Name:"+name);
}
}
class Test extends Student
{
int marks1,marks2;
void get_marks()
{
Scanner sc=new Scanner(System.in);
System.out.println("Enter Class Test-1 Marks:");
marks1=sc.nextInt();
System.out.println("Enter Class Test-2 Marks:");
marks2=sc.nextInt();
}
void disp_marks()
{
System.out.println("Marks-1:"+marks1);
System.out.println("Marks-2:"+marks2);
}
}
class Result extends Test
{
int total;
void disp_total()
{
total=marks1+marks2;
System.out.println("Total Marks:"+total);
}
}
class MultilevelInheritance
{
public static void main(String args[])
{
Result r1=new Result();
r1.get_stud_info();
r1.get_marks();
r1.disp_stud_info();
r1.disp_marks();
r1.disp_total();
}
}