-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSingleInheritance.java
More file actions
48 lines (44 loc) · 865 Bytes
/
SingleInheritance.java
File metadata and controls
48 lines (44 loc) · 865 Bytes
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
class Student
{
int admno;
String name;
void get(int admno,String name)
{
this.admno=admno;
this.name=name;
}
void show()
{
System.out.println("Admission no="+admno);
System.out.println("Name="+name);
}
}
class Marks extends Student
{
int mat,phy,che;
void getMarks(int mat,int phy,int che)
{
this.mat=mat;
this.phy=phy;
this.che=che;
}
void showMarks()
{
System.out.println("Maths="+mat);
System.out.println("Physics="+phy);
System.out.println("Chemistry="+che);
System.out.println("Total="+(mat+phy+che));
System.out.println("Average="+(mat+phy+che)/3);
}
}
class Single
{
public static void main(String[] args)
{
Marks m1=new Marks();
m1.get(402,"NAWAZ");
m1.getMarks(85,67,78);
m1.show();
m1.showMarks();
}
}