单选题:以下是应用程序中定义的静态方法printBinary,若在其main方法中有方法调用语句printBinary
以下Java应用程序中定义的静态方法printBinary,若在main方法中有方法调用语句printBinary(2),则该语句输出的结果是 ?
static void printBinary(int i) {
system.out.print(i + "的2进制数表示为:\t");
for(int j = 31; j >=0; j--)
if(((1 << j) & i) != 0)
system.out.print("1");
else
system.out.print("0");
system.out.println();//换行
}
A.00000000000000000000000000000001
B.00000000000000000000000000000010
C.00000000000000000000000000001111
D.00000000000000000000000000000000
答案:B
static void printBinary(int i) {
system.out.print(i + "的2进制数表示为:\t");
for(int j = 31; j >=0; j--)
if(((1 << j) & i) != 0)
system.out.print("1");
else
system.out.print("0");
system.out.println();//换行
}
A.00000000000000000000000000000001
B.00000000000000000000000000000010
C.00000000000000000000000000001111
D.00000000000000000000000000000000
答案:B