πŸ“Š JAVA
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
πŸ’¬ Discuss
βœ… Correct Answer: (B) Prints Binary representation of a number

You must be Logged in to update hint/solution

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
352
Total Visits
πŸ“½οΈ
4 y ago
Published
πŸŽ–οΈ
Ram Sharma
Publisher
πŸ“ˆ
90%
Success Rate