Java Foundations — Question 29

Which statement is true about a Java method?

Answer options

Correct answer: B

Explanation

The correct answer is B because in Java, methods cannot be nested within other methods. Option A is incorrect because while it is common to declare methods with an access modifier, it is not mandatory. Option C is also wrong since a method can be defined without parameters or a return value. Option D is incorrect; a method can be declared as static, but the term 'static final' is not applicable to methods.