etnie1031 etnie1031 -4 years ago 99
Java Question

Why is this not a legal method signature?

On my practice exam, the following question was asked:

Which of the following are legal method signatures?

a) public void int foo()

b) private static int foo()

c) double foo(a, b)

d) String[] foo(String a, String b)

e) String foo(int a, String[] b)


I think option A is illegal, since you can't put "void" AND "int", right?

I think option B is fine, and I THOUGHT option C was legal too, but the answer key marks C as an illegal method signature.

I'm having trouble understanding why options D and E are legal, but option C isn't? Any ideas?

Answer Source
double foo(a, b)

The types of the parameters are missing.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download