Answers for "inheritance in constructor java"

4

Inheritance in java

// Hierarchical inheritance in java
class Animal
{
   void eating()
   {
      System.out.println("animal eating");
   }
}
class Lion extends Animal
{
   void roar()
   {
      System.out.println("lion roaring");
   }
}
public class Dog extends Animal
{
   void bark()
   {
      System.out.println("dog barking");
   }
   public static void main(String[] args)
   {
      Animal obj1 = new Animal();
      obj1.eating();
      Lion obj2 = new Lion();
      obj2.eating();
      obj2.roar();
      Dog obj3 = new Dog();
      obj3.eating();
      obj3.bark();
   }
}
Posted by: Guest on November-23-2020
2

inheritance in java

Inheritance in Java is a mechanism in which one object acquires 
all the properties and behaviors of a parent object.
It is an important part of OOPs (Object Oriented programming system).
Posted by: Guest on May-03-2021
0

inheritance in java

class Arithmetic {
    Arithmetic() {}
}

class Adder extends Arithmetic {
    Adder() {}
    
    int add(int a, int b) {
        return a + b;
    }
}
Posted by: Guest on August-10-2021

Code answers related to "inheritance in constructor java"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language