KnowledgeBoat Logo

Computer Applications

What is the method to check whether a character is a letter or digit?

  1. isDigit(char)
  2. isLetterOrDigit()
  3. isLetterOrDigit(char)
  4. isLETTERorDIGIT(char)

Java Library Classes

ICSE 2024

1 Like

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:

  1. isDigit(char) – This method only checks if the character is a digit, not a letter.
  2. isLetterOrDigit() – Incorrect because this method requires a character parameter.
  3. isLETTERorDIGIT(char) – Java methods are case-sensitive, and method names follow camelCase. This method name does not exist.

Answered By

1 Like


Related Questions