JAVA

inheritance

How to Create Inheritance in JAVA

In this article, you will learn How to Create Inheritance in JAVA.

Example:-

class Vehicle {
  protected String brand = "Samsung";
  public void honk() {
    System.out.println("Mobile, LED!");
  }
}

class Car extends Vehicle {
  private String modelName = "Galaxy";
  
abstraction in java

How to Create Polymorphism in JAVA

In this article, you will learn How to Create Polymorphism in JAVA.

Example:-

class Animal {
  public void animalSound() {
    System.out.println("The animal makes a sound");
  }
}

class Pig extends Animal {
  public void animalSound() {
    System.out.println("The pig says: