Abstract Method in Class: Prof. Kumar Anand Singh
Abstract Method in Class: Prof. Kumar Anand Singh
Syntax:
If you observe the Shape class serves in our goal of achieving abstract class Shape{
inheritance and polymorphism. But it was not built to be // code
instantiated. Such classes can be labeled Abstract. An abstract }
class can not be instantiated.
Prof. Kumar Anand Singh
What are Abstract Methods?
• An Abstract Method is a method that has just the method definition but
does not contain implementation.
• As we all know, the formula for calculating area for rectangle, circle, &
triangle is different. The calculateArea() method will have to be
overridden by the inheriting classes. It makes no sense defining it in the
Shape class, but we need to make sure that all the inheriting classes do
have the method.
• Such methods can be labeled abstract.
Syntax:
abstract public void calculateArea();