LEC : 22 | java

           

LEC:22

Inheritance in JAVA| single level inheritance|Multilevel inheritance| Hierarchical inheritance| Why java doesn't support Multiple inheritance | what to use instead of multiple inheritance


  



Source Code:
package oops;
import java.util.Scanner;
class Student {
    protected int roll;
    protected String name;
    public
    void set(int a1,String b1)
    {
        roll=a1;
        name=b1;
    }
    void get()
    {
        System.out.println("Student roll no.  : "+roll+" and Name is  : "+ name);
    }
}
class Marks extends Student{
 protected int mark;
    public 
         void getMark(int a)
         {
             mark=a;
              
         }
         void display()
         {
             System.out.println("Student roll no.  : "+roll+" and Name is  : "+ name
                     +" Marks of the "+name +" = "+mark);
         }
}
class sports extends Marks {
    private int sportMark;
    public 
         void getSportMark(int a)
         {
             sportMark=a;
              
         }
         void displaySports()
         {
             System.out.println("Student roll no.  : "+roll+" and Name is  : "+ name
                     +"\n Marks of the "+name +" = "+mark+"\nsports mark is : "+sportMark);
         }
}
public class OOPS {
    public static void main(String[] args) {
        sports O1=new sports();
        O1.set(2, "Neha");
        O1.get();
        O1.getMark(59);
//        O1.display();
        O1.getSportMark(89);
        O1.displaySports();
    }

}


Comments

Popular posts from this blog

RunwayWithCode

web development Lectures

C++ Lectures