Discussion
What will be the output of the program?
public class Item32
{
void execute()
{
char letter = 'a';
char upper = Character.toUpperCase(letter);
System.out.println(upper + " " + (int) upper);
}
public static void main(String[] args)
{
Item32 demo = new Item32();
demo.execute();
}
}
Answer: D
toUpperCase returns the char A, which prints as the letter, while the explicit cast to int prints its code point 65. A char concatenated into a string shows the character; cast to int it shows the number. Lower case a would have been 97.
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