Abstract Class and Interface part1

Опубликовано: 25 Март 2026
на канале: Solario Tech
138
4

An abstract class is a class that is declared abstract —it may or may not include abstract methods. Abstract classes cannot be instantiated, but they can be subclassed. When an abstract class is subclassed, the subclass usually provides implementations for all of the abstract methods in its parent class.

Program:

abstract class Birds
{

abstract void flying();



}

class Sparrow extends Birds
{

void flying()
{
// Flying Functionality

System.out.println("Sparrow Flyinggggg");

}

}

class Eagle extends Birds{

void flying()
{
// Non Flying Functionality

System.out.println("Eagle Flyinggggg");
}

public static void main(String args[])
{
Eagle e1=new Eagle();
e1.flying();
Sparrow s1=new Sparrow();
s1.flying();

}
}