Menu
Question Index
...

What will be the output of the following program?

public class Convert {

    public void printBinaryFormat(int dec) {
        int bin[] = new int[15];
        int temp = 0;
        while (dec > 0) {
            bin[temp++] = dec % 2;
            dec = dec / 2;
        }
        System.out.print("After binary conversion: ");
        for (int i = temp - 1; i >= 0; i--) {
            System.out.print(bin[i]);
        }
    }

    public static void main(String a[]) {
        Convert dec = new Convert();
        dec.printBinaryFormat(8489);
    }
}


After binary conversion: 10000100101001
After binary conversion: 10000110001100
After binary conversion: 10000100100100
Compilation Error or Runtime Error

Doubts

Problems

Topic: Static and Non Static Variables - Static and Non Static Methods

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App