Discussion
What will be the output of the program?
public class Program64
{
void execute()
{
boolean underscoreOk = Character.isLetterOrDigit('_');
boolean tabIsSpace = Character.isWhitespace('\t');
System.out.println(underscoreOk + " " + tabIsSpace);
}
public static void main(String[] args)
{
Program64 demo = new Program64();
demo.execute();
}
}
Answer: D
An underscore is neither a letter nor a digit as far as Character is concerned, despite being legal in identifiers, so the first test is false. A tab is whitespace, so the second is true. Identifier rules and character classification are separate questions.
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