Exam 1z0-811 All QuestionsBrowse all questions from this exam
Question 4

Which statement is true about a Java method?

    Correct Answer: B

    A Java method cannot be defined within another method. Methods are defined within a class, but not inside each other. This is a fundamental aspect of the structure of Java code. Therefore, the statement that a Java method cannot be defined within another method is true.

Discussion
EligiOption: B

A is not correct, because if no modifier is added to method, by default java will add 'protected' modifier. B is the correct answer.

AnuOption: A

In Java, every method must be declared with an access modifier, which defines the visibility of the method. The access modifiers include public, private, protected, and package-private (default). The choice of access modifier determines where the method can be accessed from.

supercoderOption: B

B is correct. will result in compile time error

tabrezshaikh13Option: B

B is the correct answer as we cannot have a method inside another method.