JAVA What is the public interface of a class How does it dif
((JAVA))
What is the public interface of a class? How does it differ from the implementation of a class?
Solution
Public interface:
The public interface of a class are its public properties such as variables or fields you can read the values of or assign to and methods.
Here create something that is not a subclass of LinkedList. Constructing a subclass would give you access to protected methods.
\"Public interface of linked list class\" means only public methods of the LinkedList class.
Difference in Interface and Implementation :
Implementation is somewhat equal to Abstract class, Abstract class can have abstract and non-abstractmethods. Interface can have only abstract methods.
Abstract class doesn\'t support multiple inheritance. Interface supports multiple inheritance.
Abstract class can have final, non-final, static and non-static variables. Interface has only static and final variables.
Example for abstract class:
public abstract class Shape{
public abstract void draw();
}
Example for interface class:
public interface Drawable{
void draw();
}
