Java OCA OCP Practice Question 1358

Question

Which of the following are valid Java identifiers?

Choose all that apply

A.   A$B 
B.   _helloWorld 
C.   true 
D.   java.lang 
E.   Public 
F.   2020_s 


A, B, E.

Note

Option A is valid because you can use the dollar sign in identifiers.

Option B is valid because you can use an underscore in identifiers.

Option C is not a valid identifier because true is a Java reserved word.

Option D is not valid because the dot (.) is not allowed in identifiers.

Option E is valid because Java is case sensitive, so Public is not a reserved word and therefore a valid identifier.

Option F is not valid because the first character is not a letter, $, or _.




PreviousNext

Related