CHAPTER 7

Abstract Classes and Interfaces

In Chapter 6, we have looked at the keyword final, let us now look at another keyword in Java called abstract. The keyword abstract in a sense is opposite of final. It is a modifier only for methods and classes. The modifiers abstract and final cannot be used together. A method or a class cannot be declared to be both abstract and final. A final method prevents overriding, whereas an abstract method promotes overriding. A final class prevents inheritance, whereas an abstract class promotes inheritance.

7.1 ABSTRACT CLASSES AND ABSTRACT METHODS

What is the meaning of declaring a method as abstract. When we declare a method as abstract, then we do not provide an implementation of the method, and the method ...

Get The class of Java now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.