abstract in java

Abstract:                                                         
                                The abstraction is a process of hiding implementation details and showing functionality. The abstraction can be achieved by using abstract classes and by using interfaces (100% abstraction).

   
Abstract class:

                                It is a methodology hiding implementation details. A class which is declared with “abstract” keyword is known as Abstract class.
The abstract class least contain single abstract method and it can have non-abstract methods.The  object creation is not possible to abstract class. If you inherit abstract class into child class must implement all the methods present in the superclass. We can inherit abstract class into its child classes only.

Syntax:
                abstract  class classname{
                //abstract methods
                //variables
                //non-abstract methods
                }

Abstract method:
                                In abstract class a method declared with the abstract keyword is known as an abstract method. A method is declared with abstract keyword but not defined is known as an abstract method. The abstract method doesn’t have a body. The abstract methods can extend within the subclass.

Syntax:
                abstract class classname{
                abstract void salary();
                //variables
                //non-abstract methods
                }

Interview Questions:

What is abstraction?
Define about abstract class and method?
What are the differences between abstract method and non-abstract method?
How can we achieve 100% abstraction?
what are the differences between abstract class and normal java class?

Differnces between abstract class and interface


EmoticonEmoticon