JAVA Program to Display Student Details with Marks

JAVA Program to Display Student Details with Marks:


class student
{
  int roll;
  String name;
  String cl;

  student(int rn,String n,String c)
    {
    roll=rn;
    name=n;
    cl=c;
    }

    void display()
    {
     System.out.println("Roll No. : "+roll);
     System.out.println("Name     : "+name);
     System.out.println("Class    : "+cl);
    }
 }

 class marks extends student
 {
    int m1,m2,m3;
    marks(int rn,String n,String c,int x,int y,int z)
    {
    super(rn,n,c);
    m1=x;
    m2=y;
    m3=z;
    }
  
    void dispmarks()
    {
     System.out.println("Roll No. : "+roll);
     System.out.println("Name     : "+name);
     System.out.println("Class    : "+cl);
     System.out.println("Mark 1   : "+m1);
     System.out.println("Mark 2   : "+m2);
     System.out.println("Mark 3   : "+m3);
    }
 }

 class student_inher
  {
   public static void main(String arg[])
   {
    marks m = new marks(11,"SACHIN","MBA-IT",67,78,89);
   
   m.dispmarks();
   }
 }

OUTPUT:

Roll No. : 11
Name     : SACHIN
Class    : MBA-IT
Mark 1   : 67
Mark 2   : 78
Mark 3   : 89

Leave a Reply

Your email address will not be published. Required fields are marked *

2 × two =