Important Java Mcq 1

Which one of these is a valid method declaration?

a. void method1

b. void method2()

c. void method3(void)

d. method(void)

Answer:

b. void method2()

Explanation:

The declaration of any method should be in the format of returnType methodName(parameter1, parameter2, ….). Since all the other options are violating the syntax of writing a method, so b is the correct Choice.

Related MCQs
Aniket Malik

Aniket Malik

CERTIFIED TUTOR/TRAINER WITH 300+ REVIEWS

Facing difficulty with

this concept?