Menu
Question Index
...

What will be the output of the following program?

public class PrintStatment13
{
    public int getValue(int binary)
    {
        int decimal = 0;
        int power = 0;
        while (true)
        {
            if (binary == 0)
            {
                break;
            }
            else
            {
                int tmp = binary % 10;
                decimal += tmp * Math.pow(2, power);
                binary = binary / 10;
                power++;
            }
        }
        return decimal;
     }
     public static void main(String a[])
     {
        PrintStatment13 bd = new PrintStatment13();
        System.out.println(bd.getValue(100110));
     }
}


38
11
12
25
Compilation Error or Runtime Error

Doubts

Problems

Topic: Behavior Of Java Classes Using Methods

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App