Given: interface B { int a; void methodA(); } no problem the method needs to be public the variable a must be assigned a value the method needs to have a body Question 16 0.5 pts
An Interface just like a class but it is not class.Interface contains variable and methods which are abstract by default(methods signature,No body). Methods and variable define in an interface are public, static and final by default.
The methods used in interface for full abstraction.methods in interfaces do not have body. To access them need to implement by the class .the class implement the interface must implement all the methods of class
An interface is used to achieve abstraction.interface not allowed the multiple inheritance.
Syntax of an interface:
Interface{
//declare constant field
//declare methods that abstract by default
}
Or
interface interface1
{
/*all the methods are public abstract by default and they have not body */
public void method();
public void method();
}
Step by step
Solved in 2 steps