. . .

when we extending an existing class, we have a choice whether to redefine the methods of the superclass. Abstract classes in java Basically a superclass has common features that are shared by subclasses. In some cases, you will find that superclass cannot have any instance (object) and such classes are called abstract classes.

Abstract classes usually contain abstract methods. An abstract method is a method signature (declaration) without implementation. Basically these abstract methods provide a common interface to different derived classes. Abstract classes are generally used to provide common interface derived classes.

You know a superclass is more general than its subclass(es). The superclass contains elements and properties common to all of the subclasses. Often, the superclass will be set up as an abstract class, which does not allow objects of its prototype to be created. In this case, only objects of the subclass are created. To do this the reserved word abstract is included (prefixed) in the class definition.

abstract class in java
abstract class in java
abstract class shape {
		int b = 20;
			abstract public void calculateArea();

public class Rectangle extends shape {
	public static void main(String args[]) {
		Rectangle obj = new Rectangle();
			obj.b = 200;
	public void calculateArea() {
		System.out.println("Area is " + ("obj.b * obj.b"));
Please share the article

Leave a Reply

Your email address will not be published. Required fields are marked *

19 − 14 =