Computer Applications
What is the method to check whether a character is a letter or digit?
- isDigit(char)
- isLetterOrDigit()
- isLetterOrDigit(char)
- isLETTERorDIGIT(char)
Answer
isLetterOrDigit(char)
Reason — In Java, the method Character.isLetterOrDigit(char ch) is used to check whether a given character ch is either a letter (A-Z or a-z) or a digit (0-9).
Analysing Other Options:
isDigit(char)– This method only checks if the character is a digit, not a letter.isLetterOrDigit()– Incorrect because this method requires a character parameter.isLETTERorDIGIT(char)– Java methods are case-sensitive, and method names follow camelCase. This method name does not exist.