Digging into JAVA — Chapter 08

Hello everyone, Today I am going to talk about “Interfaces and Abstract classes”.

Abstract class: An abstract class indicates that no new instances of that class may ever be created. We may still use that abstract class as a stated reference type for polymorphism, but we don’t have to worry about anyone creating instances of that type. It is guaranteed by the compiler.

Unless it is expanded, an abstract class has almost no utility, value, or purpose in life. The men performing the job at runtime with an abstract class are instances of a subclass of your abstract class.

Abstract and Concrete Classes: A concrete class is one that is not abstract. We only instantiate a specific subclass of Component, never the Component itself.

Abstract methods: An abstract class indicates that the class must be expanded, whereas an abstract method indicates that the method must be overridden. The abstract technique, in particular, lacks a body. As a result, we avoided using curly brackets and simply ended the declaration with a semicolon. If we include even one abstract method in a class, we must make the class abstract. However, in the abstract class, we can mix abstract and non-abstract methods. Abstract methods lack a body and exist merely to support polymorphism. That is, all abstract methods must be implemented by the first concrete class in the inheritance tree.

Interface: Interface is a completely abstract class. A Java interface addresses your many inheritance dilemmas by providing many of the polymorphic benefits of multiple inheritances while eliminating the anguish and suffering caused by the Deadly Diamond of Death.

That’s it from this story. Have a nice day! 👋




Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Gagani Senarathne

Hello everyone, I am Gagani Senarathne and I have 2+ years of experience and currently I am an Associate Engineer (Technology) at Virtusa Pvt Ltd.