0% found this document useful (0 votes)
5 views1 page

Abstract Class&methods

An abstract class in Java cannot be instantiated and may contain both abstract methods (without a body) and concrete methods (with a body). An abstract method must be declared within an abstract class or interface, is not implemented in the abstract class, and must be overridden in a subclass. Abstract methods are used to enforce a common method structure across subclasses while allowing for different implementations.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views1 page

Abstract Class&methods

An abstract class in Java cannot be instantiated and may contain both abstract methods (without a body) and concrete methods (with a body). An abstract method must be declared within an abstract class or interface, is not implemented in the abstract class, and must be overridden in a subclass. Abstract methods are used to enforce a common method structure across subclasses while allowing for different implementations.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

what is abstract class ?

🔹 Definition:
An abstract class in Java is a class that cannot be instantiated (cannot create an
object of that class directly)
and may contain abstract methods (methods without a body) as well as concrete
methods (methods with a body).
To use an abstract class you have to inherite it from sub class (abstarct class
must be super class)

syntax : abrtact className{ }

what is abstract method ?


🔹 Definition:
An abstract method is a method without a body . It is declared using the abstract
keyword inside an abstract class or an interface.

🔹 Key Features of an Abstract Method


Declared but not implemented in the abstract class.

Must be overridden in a subclass.

Ends with a semicolon (;) instead of a method body { }.

Forces subclasses to provide their own implementation.

Use an abstract method when:

✅ You want to enforce a common method across all subclasses but with different
implementations.
✅ You don't know the exact implementation yet, but you want to define the method
structure.

You might also like