Question discussion

Which of the following is the correct way to define a function in Java?

359057Medium DSSSB TGT Computer Science 0 replies 0 views
0
Which of the following is the correct way to define a function in Java?
  • Apublic void myFunction() {}
  • Bfunction myFunction() {}
  • Cdef myFunction() {}
  • DPublic myFunction() {}
Correct answer: A

Explanation

A Java method is written like "public void myFunction() {}". The other forms belong to JavaScript or Python.

Discussion 0

Nobody has replied yet. Start the discussion!