Singularity
Singularity

Reputation: 89

Can a class be abstract and concrete at the same time in java?

Have a doubt :

Can a class be abstract and concrete at the same time in java? i.e if an abstract class has no abstract methods in it, then can it be called a concrete class. Also can we say that any and every class that has no abstract method be called a concrete class?

Upvotes: 2

Views: 253

Answers (2)

Erwin Bolwidt
Erwin Bolwidt

Reputation: 31279

The answers are "no" and "no". Abstract classes are only those that have been declared with the keyword abstract, whether or not they contain abstract methods. A non-abstract class is not allowed to contain abstract methods.

Upvotes: 3

gtgaxiola
gtgaxiola

Reputation: 9331

The main difference lies in the documentation where it states:

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.

Instantiation is the key here.

Upvotes: 5

Related Questions