Java OCA OCP Practice Question 1238

Question

Which of the following is a valid method name in Java?

A.   $asdf() 
B.   \asdf13() 
C.   walk#() 
D.   %run() 


A.

Note

Java methods must start with a letter, the dollar $ symbol, or underscore _ character.

For these reasons, Options B and D are incorrect, and Option A is correct.

Option C is incorrect.

The hash tag (#) symbol cannot be included in a method name.




PreviousNext

Related