Hackerrank Can You Access? Solution

Hackerrank Can You Access? Solution

You are given a class Solution and an inner class Inner.Private. The main method of class Solution takes an integer  as input. The powerof2 in class Inner.Private checks whether a number is a power of . You have to call the method powerof2 of the class Inner.Private from the main method of the class Solution.


Sample Input


Sample Output

8 is power of 2
An instance of class: Solution.Inner.Private has been created

Solution in java8

Approach 1.

o = new Inner().new Private();
System.out.printf("%d is %s \n",num,((Inner.Private)o).powerof2(num));
			//Write your code here

Approach 2.

			System.out.println(num + " is " + ((Solution.Inner.Private)(o = (Object) new Solution.Inner().new Private())).powerof2(num));

Approach 3.

			//Write your code here
            o = new Inner().new Private();
            System.out.println(num + " is " + ((Solution.Inner.Private)o).powerof2(num));