Discussion
What will be the output of the program?
public class Item24
{
void execute()
{
String bits = Integer.toBinaryString(10);
String hex = Integer.toHexString(255);
System.out.println(bits + " " + hex);
}
public static void main(String[] args)
{
Item24 demo = new Item24();
demo.execute();
}
}
Answer: D
toBinaryString and toHexString return the digits alone, with no 0b or 0x prefix, and the hexadecimal letters are lower case. So 10 becomes 1010 and 255 becomes ff. Upper case would need toUpperCase() on the result.
No comment is present. Be the first to comment.
Loading…
Post your comment
Please log in or register to post a comment.
Examination Categories
- SSC Exams
- Banking Exams
- Teaching Exams
- Civil Services Exams
- Railways Exams
- Engineering Recruitment Exams
- Defence Exams
- State Government Exams
- Police Exams
- Insurance Exams
- Nursing Exams
- Other Government Exams
- NRA CET
- PG Entrance Exams
- Campus Placement
- MBA Entrance Exams
- CUET and UG Entrance
- Judiciary Exams
- Regulatory Body Exams
- Software Development