Hackerrank Can You Access? Solution
1 min read

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));

Enjoying these posts? Subscribe for more

Adblocker detected! Please consider reading this notice.

We've detected that you are using AdBlock Plus or some other adblocking software which is preventing the page from fully loading.

That's okay. But without advertising-income, we can't keep making this site awesome.

We don't have any banner, Flash, animation, obnoxious sound, or popup ad. We do not implement these annoying types of ads!

We need money to operate the site, and almost all of it comes from our online advertising.

Please add thepoorcoder.com to your ad blocking whitelist or disable your adblocking software.