L

@Leela1571

Multiple inheritance modified

Java
3 years ago
interface accelerate{ public void acceleratemethod(); } interface brake{ public void brakemethod(); } class car implements accelerate,brake{ car(){ System.out.println("car implements both accelerate and brake methods"); }

MultipleInheritanceUsingInterface

Java
3 years ago
//to implement multiple inheritance, interface must be used interface accelerate{ public void acceleratemethod(); } interface brake{ public void brakemethod(); } class car implements accelerate,brake{ public void acceleratemethod()

hierarchical inheritance

Java
3 years ago
//only one parent class remaining all are child classes class animal{ animal(){ System.out.println("this is animal class"); } public void eat(){ System.out.println("it is eating"); } } class cat extends animal{

multilevel inheritance

Java
3 years ago
class animal{ animal(){ System.out.println("this is parent class animal"); } } class cat extends animal{ cat(){ System.out.println("this is cat class"); } }

encapsulation getter setter

Java
3 years ago
class employee{ //encapusulation is possible, by declaring variables with private keyword String name; int id; public String getname(){ return name; } public void setname(String newname){ name=newname; }

inheritance example 1

Java
3 years ago
class employee{ String name; int id; employee(String name,int id){ this.name=name; this.id=id; } public void introduce(){ System.out.println("I am "+name); }

run time polymorphism

Java
3 years ago
//run time polymorphism class parent{ public void display(){ System.out.println("this is a parent class"); } } class child extends parent{ public void display(){ System.out.println("this is a child class"); }

compile time polymorphism

Java
3 years ago
//compile time polymorphism class Adder{ public int add(int a, int b){ return a+b; } public long add(long a, long b){ return a+b; } } public class Main{

oops3

Java
3 years ago
class person{ private String fname; private String lname; public String getfname(){ return fname; } public void setfname(String fname){ this.fname=fname; } public String getlname(){

oops2

Java
3 years ago
class student{ String name; int rollno; int age; void info(){ System.out.println("Name: "+name); System.out.println("rollno: "+rollno); System.out.println("Age: "+ age); } }

oops1

Java
3 years ago
public class Main{ String name; int rollno; int age; void info(){ System.out.println("Name: "+name); System.out.println("rollno: "+rollno); System.out.println("age: "+age); }