A

Admin • 830.13K Points
Coach

Q. What does this Java code snippet prints?

Code:
int b=45;
String str="";
while(b > 0)
{
str = str + b%2;
b = b/2;
}
StringBuilder sb = new StringBuilder(str);
sb.reverse();
System.out.println(sb.toString());
  • (A) Prints the remainder of a number
  • (B) Prints Binary representation of a number
  • (C) Prints Octal representation of a number
  • (D) Prints Hexadecimal representation of a number
  • Correct Answer - Option(B)
  • Views: 13
  • Filed under category Java
  • Hashtags:

No solution found for this question.
Add Solution and get +2 points.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.