0 votes
in JAVA by

What is meant by Interface?

Multiple inheritance cannot be achieved in java. To overcome this problem Interface concept is introduced.

An interface is a template which has only method declarations and not the method implementation.

Example:

1

Public abstract interface IManupulation{ //Interface declaration

2

Public abstract void add();//method declaration

3

public abstract void subtract();

4

}

All the methods in the interface are internally public abstract void.

All the variables in the interface are internally public static final that is constants.

Classes can implement the interface and not extends.

The class which implements the interface should provide an implementation for all the methods declared in the interface.

view sourceprint?

1

public class Manupulation implements IManupulation{ //Manupulation class uses the interface

2

Public void add(){

3

……………

4

}

5

Public void subtract(){

6

…………….

7

}

8

}

Related questions

+1 vote
asked May 24, 2019 in JAVA by rajeshsharma
+1 vote
asked May 24, 2019 in JAVA by rajeshsharma
...