Posts

Showing posts with the label abstraction

Interface VS Abstract class

Difference  abstract class vs interface Abstract class 1)Abstract class can have both an abstract as well as concrete methods. 2) Multiple Inheritance is not supported in abstract class. 3) final, non-final, static , non-static variables are supported. 4) Abstract class declared using abstract keyword. 5) Abstract class can be inherited using extends keyword. 6) Abstract class can have any type of members like private, public.

MARKER INTERFACE IN JAVA

Image
  MARKER INTERFACE 

ABSTRACTION IN JAVA

Image
  Abstract class in Java A class which is declared with the abstract keyword is known as an abstract class in java. It can have abstract and non-abstract methods (method with the body). Abstraction in Java Abstraction  is a process of hiding the implementation details and showing only functionality to the user. Points An abstract class must be declared with an abstract keyword. It can have abstract and non-abstract methods. It cannot be instantiated. It can have constructe and static methods also. It can have final methods which will force the subclass not to change the body of the method. Abstract Method in Java A method which is declared as abstract and does not have implementation is known as an abstract method. abstract void print(); //no method body and abstract eg - // Abstract class abstract class Animal {   // Abstract method    public abstract void animalSound();   // Regular method   public void eat() {     System.out.println("...