JAVA OOP Example #4

class Student{

  int rollno;

  String name;

  int m1;

  int m2;

  int m3;

  int T;

  Student(){

    this.rollno=04;

    this.name="Roshan Bhardwaj";

    this.m1=41;

    this.m2=43;

    this.m3=36;

    this.T=m1+m2+m3;

  }

  Student(int rollno,String name,int m1,int m2,int m3){

    this.rollno=rollno;

    this.name=name;

    this.m1=m1;

    this.m2=m2;

    this.m3=m3;

    this.T=m1+m2+m3;

  }

  public void printdetails(){

    System.out.println("Rollno:"+rollno);

    System.out.println("Name:"+name);

    System.out.println("Marks1:"+m1);

    System.out.println("Marks2:"+m2);

    System.out.println("Marks3:"+m3);

    System.out.println("Total Marks:"+T);

  }

  

}

class Result extends Student{

 public void getResult(){

  if(T>40){

    System.out.println("Congratulation You are Pass");

  }

  else{

    System.out.println("You are Fail,Try Next Time");

  }

 }

}

class main{

  public static void main(String[] args){

    Student stud1=new Student();

    stud1.printdetails();

    Result res=new Result();

    res.getResult();

  }

}


Comments

Post a Comment

Popular posts from this blog

ONE TO ONE CHAT APP