Skip to content
the poor coder

Hackerrank Can You Access? Solution

Poor Man
Published
Updated
Reading time
1 min read

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.

Constraints

Sample Input

Text
8

Sample Output

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

Solution in java8#

Approach 1.

Python

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

Approach 2.

Python


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

Approach 3.

Python


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

Keep going

ESC