Asked by HANNAH MARTE on Jun 24, 2024

verifed

Verified

Which of the following is a valid char value?

A) '$_'
B) '%'
C) 'n\'
D) "a"

Valid Char

A character that is allowed or recognized by a specific programming language or input field based on predefined criteria.

  • Understand and identify valid character and string literals in Java.
verifed

Verified Answer

SM
siddhi munjaniJun 28, 2024
Final Answer :
B
Explanation :
Option B is a valid char value as it represents a single character enclosed in single quotes. Option A is not valid as the '_' symbol is not allowed in a char value. Option C is not valid as the backslash needs to be escaped to be included in a char value. Option D is valid but is a string value enclosed in double quotes, not a char value.