Home Interfaces in java

Interfaces in java

Interfaces is nothing but another way to implement the Abstractions.only the different is Abstractions we are using super class and subclass to inherit using extends keyword but interface we are using implements keyword thats all.

Create a interface Calculator.


public interface Calculator {

    public int Total(int num1,int num2);

Create a Class CalculatorImpl.


public class CalculatorImpl implements Calculator {
    public int Total(int num1, int num2) {
        return num1 + num2;


public class Main {
    public static void main(String args[]) {
        Calculator calculator = new CalculatorImpl();
        int result = calculator.Total(10,30);




Comments are closed.