Core Java - Interface
Saravanan B
Posted on February 14, 2023
Interface Fully Abstract methods.
public interface Car {
void go();
void stop();
}
public class Honda implements Car{
@Override
public void go() {
System.out.println("Implemented go method");
}
@Override
public void stop() {
System.out.println("Implemented stop method");
}
}
public class Test {
public static void main(String[] args) {
Honda h = new Honda();
h.go();
h.stop();
}
}
An interface is a contract whereas Abstract method contains partial implementation.
An interface is by default public abstract method.
Variable in interface is public static final and should be initialized.
cannot define blocks and constructor.
💖 💪 🙅 🚩
Saravanan B
Posted on February 14, 2023
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.