Challenge 2: Implement an Interface

Can you implement an interface in your class? A solution is placed in the "solution" section to help you, but we would suggest you try to solve it on your own first.

Problem Statement

You are given an interface Addition which contains a method signature int add(int num1, int num2). You need to write a class called Calculator which implements the Addition interface.

The add(int, int) method takes two integers and returns their sum.

Input

Calls the add(int, int) method by passing num1 and num2.

Output

Returns the addition of num1 and num2.

Sample Input

Calculator cal = new Calculator();
cal.add(10, 20);

Sample Output

30

Get hands-on with 1400+ tech skills courses.