-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchit22.java
73 lines (58 loc) · 1.92 KB
/
chit22.java
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
//~Create a class Student having abstract member functions to get name, SSC marks, HSC marks, create 3 classes Harish, Jayant and Vijay who extend Student class and implement the abstract methods and print the student details.
abstract class Student {
// abstract method to get the name of the student
public abstract String getName();
// abstract method to get the SSC marks of the student
public abstract int getSSCmarks();
// abstract method to get the HSC marks of the student
public abstract int getHSCmarks();
}
class Harish extends Student {
// implementation of the abstract methods
public String getName() {
return "Harish";
}
public int getSSCmarks() {
return 85;
}
public int getHSCmarks() {
return 90;
}
}
class Jayant extends Student {
// implementation of the abstract methods
public String getName() {
return "Jayant";
}
public int getSSCmarks() {
return 80;
}
public int getHSCmarks() {
return 95;
}
}
class Vijay extends Student {
// implementation of the abstract methods
public String getName() {
return "Vijay";
}
public int getSSCmarks() {
return 75;
}
public int getHSCmarks() {
return 88;
}
}
public class chit22 {
public static void main(String[] args) {
Student harish = new Harish();
Student jayant = new Jayant();
Student vijay = new Vijay();
System.out.println("Name: " + harish.getName() + ", SSC marks: " + harish.getSSCmarks() + ", HSC marks: "
+ harish.getHSCmarks());
System.out.println("Name: " + jayant.getName() + ", SSC marks: " + jayant.getSSCmarks() + ", HSC marks: "
+ jayant.getHSCmarks());
System.out.println("Name: " + vijay.getName() + ", SSC marks: " + vijay.getSSCmarks() + ", HSC marks: "
+ vijay.getHSCmarks());
}
}