You've successfully subscribed to The Poor Coder | Hackerrank Solutions
Great! Next, complete checkout for full access to The Poor Coder | Hackerrank Solutions
Welcome back! You've successfully signed in.
Success! Your account is fully activated, you now have access to all content.


Beeze Aal

Hackerrank Covariant Return Types Solution

Java allows for Covariant Return Types, which means you can vary your return type as long you are returning a subclass of your specified return type. Method Overriding allows a subclass to override the behavior of an existing superclass method and specify a return type that is some subclass of
Beeze Aal

Hackerrank Java Singleton Pattern Solution

"The singleton pattern is a design pattern that restricts the instantiation of a class to one object. This is useful when exactly one object is needed to coordinate actions across the system."  - Wikipedia: Singleton PatternComplete the Singleton class in your editor which contains the following components: A private Singleton
Beeze Aal

Hackerrank Java Factory Pattern Solution

According to Wikipedia, a factory is simply an object that returns another object from some other method call, which is assumed to be "new". In this problem, you are given an interface Food. There are two classes Pizza and Cake which implement the Food interface, and they both contain a
Beeze Aal

Hackerrank Java Exception Handling Solution

You are required to compute the power of a number by implementing a calculator. Create a class MyCalculator which consists of a single method long power(int, int). This method takes two integers,  and , as parameters and finds . If either  or  is negative, then the method must throw an exception
Beeze Aal

Hackerrank Java Exception Handling (Try-catch) Solution

Exception handling is the process of responding to the occurrence, during computation, of exceptions ‚Äď anomalous or exceptional conditions requiring special processing ‚Äď often changing the normal flow of program execution. (Wikipedia) Java has built-in mechanism to handle exceptions. Using the try statement we can test a block of code for errors.
Beeze Aal

Hackerrank Java Iterator Solution

Java Iterator class can help you to iterate through every element in a collection. Here is a simple example:import java.util.*;public class Example{ public static void main(String []args){        ArrayList mylist = new ArrayList();        mylist.add("Hello");        mylist.add("Java");        mylist.add("4");        Iterator it = mylist.iterator();        while(it.
Beeze Aal

Hackerrank Java Instanceof keyword Solution

The Java instanceof operator is used to test if the object or instance is an instanceof the specified type. In this problem we have given you three classes in the editor: Student classRockstar classHacker classIn the main method, we populated an ArrayList with several instances of these classes. count method
Beeze Aal

Hackerrank Java Method Overriding 2 (Super Keyword) Solution

When a method in a subclass overrides a method in superclass, it is still possible to call the overridden method using super keyword. If you write super.func() to call the function func(), it will call the method that was defined in the superclass. You are given a partially completed
Beeze Aal

Hackerrank Java Method Overriding Solution

When a subclass inherits from a superclass, it also inherits its methods; however, it can also override the superclass methods (as well as declare and implement new ones). Consider the following Sports class:class Sports{    String getName(){        return "Generic Sports";    }    void getNumberOfTeamMembers(){        System.out.println( "Each team has n players
Beeze Aal

Hackerrank Java Interface Solution

A Java interface can only contain method signatures and fields. The interface can be used to achieve polymorphism. In this problem, you will practice your knowledge on interfaces. You are given an interface AdvancedArithmetic which contains a method signature int divisor_sum(int n). You need to write a class
Beeze Aal

Hackerrank Java Abstract Class Solution

A Java abstract class is a class that can't be instantiated. That means you cannot create new instances of an abstract class. It works as a base for subclasses. You should learn about Java Inheritance before attempting this challenge. Following is an example of abstract class:abstract class Book{    String
Beeze Aal

Hackerrank Java Inheritance II Solution

.MathJax_SVG_LineBox {display: table!important} .MathJax_SVG_LineBox span {display: table-cell!important; width: 10000em!important; min-width: 0; max-width: none; padding: 0; border: 0; margin: 0} Write the following code in your editor below: A class named Arithmetic with a method named add that takes  integers as parameters and returns