Which of the following is the correct way to define a function in Java?
Show answerHide answer
Correct answer: (A) public void myFunction() {}
Explanation
In Java a method needs a return type, as in public void myFunction() {}. "function" is JavaScript syntax, "def" is Python, and "Public" (capital P) with no return type is invalid.