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.
8 is power of 2 An instance of class: Solution.Inner.Private has been created
Solution in java8
o = new Inner().new Private(); System.out.printf("%d is %s \n",num,((Inner.Private)o).powerof2(num)); //Write your code here
System.out.println(num + " is " + ((Solution.Inner.Private)(o = (Object) new Solution.Inner().new Private())).powerof2(num));
//Write your code here o = new Inner().new Private(); System.out.println(num + " is " + ((Solution.Inner.Private)o).powerof2(num));