Wednesday, November 21, 2012

STUDENT MARKSHEET USING INHERITANCE

STUDENT MARKSHEET USING INHERITANCE



/*STUDENT MARKSHEET USING INHERITANCE*/
***********************************
class student
{
protected int rollno,mark1,mark2,mark3;
student(int r,int m1,int m2,int m3)
{
rollno=r;
mark1=m1;
mark2=m2;
mark3=m3;
}
}
class score extends student
{
int scor;
score(int r,int m1,int m2,int m3,int s)
{
super(r,m1,m2,m3);
scor=s;
}
void cal()
{
System.out.println("Rollno:"+rollno);
System.out.println("Total:"+(super.mark1+super.mark2+super.mark3+scor));
}
}
class stud
{
public static void main(String args[])
{
score s1=new score(4,65,75,85,90);
s1.cal();
}
}

0 comments:

Post a Comment