Inheritance and Type of Inheritance
INHERITANCE : Inheritance Slide What is Inheritance: We can access one class properties into another class using extends keyword and reusable code purpose. Memory wastage is low. To reduce Object memory we go for inheritance. Type Of Inheritance: Single Inheritance Multilevel Inheritance Hierarchical Inheritance Multiple Inheritance Hybrid Inheritance Single Inheritance Combination Of one Parent class and one child class Single Inheritance program: Class A: package org.employee; public class Client { public void clientName() { System.out.println("swiggy"); } } Class B: package org.employee; public class Company extends Client { public void companyName() { System.out.println("HCL"); } public void companyID() { System.out.println("hc293l"); } } Multilevel Inheritance Child class is accessing more than one parent class in a tree level structure. multilevel inheritance: Class A: package org.employee; public class Client { publi...
Comments
Post a Comment