//multilevel
with constructor
class students1
{
private int sno;
private String sname;
students1(int no,String name)
{
sno = no;
sname = name;
}
public void dispstud()
{
System.out.println("Student No : " + sno);
System.out.println("Student
Name : " + sname);
}
}
class
marks1 extends students1
{
protected int mark1,mark2;
marks1(int n1,int n2,int sno,String
sname)
{
super(sno,sname);
mark1 = n1;
mark2 = n2;
}
public void dispmarks()
{
System.out.println("Mark1
: " + mark1);
System.out.println("Mark2
: " + mark2);
}
}
class
finaltot1 extends marks1
{
private int total;
finaltot1(int n1,int n2,int no,String
name)
{
super(n1,n2,no,name);
total = mark1 + mark2;
}
public void disptotal()
{
System.out.println("Total
: " + total);
}
public static void main(String args[])
{
finaltot1 f = new
finaltot1(90,89,100,"Kirthika");
f.dispstud();
f.dispmarks();
f.disptotal();
}
}
No comments:
Post a Comment