Posts

Showing posts with the label Inheritance

Inheritance in Java

Image
   Inheritance of Java The process by which one class acquires the properties(data members) and functionalities(methods) of another class is called  inheritance .  Child Class: The class that extends the features of another class is known as child class, sub class or derived class. Parent Class: The class whose properties and functionalities are used(inherited) by another class is known as parent class, super class or Base class. Syntax: Inheritance in Java class Animal {      eat() method      sleep() method } class Dog extends Animal {      bark() method } In Java, we use the  extends  keyword to inherit from a class. Here, we have inherited the  Dog  class from the  Animal  class. The  Animal  is the superclass (parent class or base class), and the  Dog  is a subclass (child class or derived class). The subclass inherits the fields...