Close sidebar

If class is declared abstract then why abstract keyword used before method in abstract class?

In abstract class we declare whole class as abstract i.e incomplete then why abstract keyword needs to declare before method?

Your Answer

n emabstract class/em is aa rel='nofollow' href="https://crbtech.in/programmes/java-training-programme" class /athat is declared abstract—it may or may not include abstract methods. Abstract classes cannot be instantiated, but they can be subclassed.br /An emabstract method/em is a method that is declared without an implementation (without braces, and followed by a semicolon), like this:br /abstract void moveTo(double deltaX, double deltaY);br /If a class includes abstract methods, then the class itself emmust/em be declared abstract, as in:br /public abstract class GraphicObject { // declare fields // declare nonabstract methods abstract void draw(); }br /When an abstract class is subclassed, the subclass usually provides implementations for all of the abstract methods in its parent class. However, if it does not, then the subclass must also be declared abstract.

Comments

Didn't get the answer.
Contact people of Talent-Core Java directly by clicking here