Multilevel inheritance Example 2
class name
{
int rollno,age;
int id(int rollno,int age)
{
//return rollno;
}
}
class mark extends name
{
int m1,m2,m3;
int marks(int m1,int m2,int m3)
{
return m1;
}
}
class total extends mark
{
int total;
void calc()
{
total=m1+m2+m3;
}
void show()
{
System.out.println("ROLLNO="+rollno+" AGE="+age+" MARK1="+m1+" MARK2="+m2+" MARK3="+m3+" TOTAL="+total);
}
}
class paramulti
{
public static void main(String args[])
{
total ob=new total();
ob.id(001,20);
ob.marks(30,30,40);
ob.calc();
ob.show();
}
}
No comments:
Post a Comment