Java OCA OCP Practice Question 819

Question

Which of the following is a valid method name in Java? (Choose two.)

  • A. _____()
  • B. %run()
  • C. check-Activity()
  • D. $Hum2()
  • E. sing\\3()
  • F. po#ut ()


A, D.

Note

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

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

Despite how Option A looks, it is a valid method signature in Java.

Options C, E, and F do not compile because the symbols -, \, and # are not allowed in method names, respectively.




PreviousNext

Related