INTERFACE
- A Java interface is a bit like a class, except a Java interface can only contain method signatures and fields
- An Java interface cannot contain an implementation of the methods, only the signature (name, parameters and exceptions) of the method.
- You can use interfaces in Java as a way to achieve polymorphism.
For Exa.
public interface MyInterface {
public String hello = "Hello"; //parameter
public void sayHello(); // method signature
}
No comments:
Post a Comment