Java OCA OCP Practice Question 391

Question

Which of the following are not legal Java identifiers?

Select 1 option

A. goto 
B. unsigned 
C. String 
D. _xyz 
E. $_abc 
F. iLikeVeryVeryVeryVeryVeryLongIdentifiersAAAAAAAAAAAAAAAAAAAAAAAll(65 characters) 


Correct Option is  : A

Note

A. is correct answer. Even though it is not used anywhere in Java code, it has been kept as a reserved word to prevent its usage in any form.

B. is not a reserved word or keyword.

For Option C. Yes, it is valid. This is a valid statement: String String = "String";

For Option D. An identifier can start with a _ sign or a $ sign.

For Option E. Can have _ or $.

For Option F. There is no restriction on the length of an identifier.

A valid java identifier is composed of a sequence of java letters and digits.

The first of which must be a letter.

It cannot be same as any java Keywords or literals (i.e. true, false or null).

Java letters include uppercase and lowercase ASCII latin letters and _ , $.

In fact, class names can serve as a valid identifier as in 'String' in one of the options above.




PreviousNext

Related