Hackerrank 30 days of code Java Solution: Day 19: Interfaces

Hackerrank Day 19 problem talk’s about one of the best features of Java and also the mostly used in live projects. Interface is like a service requirement specification for client. It tell us him what services are provided thereby without exposing the implementation to him. The main advantage of Interface is security as implementation is hidden from the client and also easy enhancement of code is possible.

Lets check out how the magic happens : Day 19

Task

The AdvancedArithmetic interface and the method declaration for the abstract divisorSum(n) method are provided for you in the editor below.
Complete the implementation of Calculator class, which implements the AdvancedArithmetic interface. The implementation for the divisorSum(n) method must return the sum of all divisors of n.

Sample Input

Sample Output

Solution to the problem is :

Thanks for the visit checkout the day 20 tutorial as well.. 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *