0

as i know interface is fully abstract class whose methods are public by default and data members are public static final. so, what is abstract interface?

public abstract interface Servlet {
public abstract void init(ServletConfig paramServletConfig)
        throws ServletException;

public abstract ServletConfig getServletConfig();

public abstract void service(ServletRequest paramServletRequest,
        ServletResponse paramServletResponse) throws ServletException,
        IOException;

public abstract String getServletInfo();

public abstract void destroy();

}

shrotriya
  • 26
  • 4

3 Answers3

2

Interfaces and their methods are abstract by default. Adding abstract doesn't mean anything different

public abstract interface example {
}

is same as

public interface example {
}

Although older versions of java required an interface to have the keyword 'abstract'. It is obsolete now and should not be used

usha
  • 28,973
  • 5
  • 72
  • 93
  • WITH THE RELEASE OF JAVA 8 WE CAN HAVE NOW DEFAULT AND STATIC IMPLEMENTED METHODS TOO INSIDE INTERFACE AND THEY ARE NOT ABSTRACT BY DEFAULT. – saurabh kumar Jul 09 '14 at 18:46
0

Interfaces are abstract by default appending abstract keyword to interface & its method signature is meaningless.

user153
  • 148
  • 1
  • 2
  • 10
0

An interface is encapsulation of final fields + abstract methods.

An abstract class may have final fields + variables + concrete methods + abstract methods

So when we are declaring abstract methods in abstract classes then we do need to write abstract keyword and if we want to declare a class to be abstract then we need to add abstract keyword to it.

But in case of interface they will only be having abstract methods. So writing abstract keyword with interface or its methods is not compulsory. They will be by default abstract.

New in Java8

Interfaces can have default methods too

gprathour
  • 14,813
  • 5
  • 66
  • 90