Which three lines are illegal?

1. class StaticMethods {
2. static void one() {
3. two();
4. StaticMethods.two();
5. three();

6. StaticMethods.four();
7. }
8. static void two() { }
9. void three() {
10. one();
11. StaticMethods.two();
12. four();
13. StaticMethods.four();
14. }
15. void four() { }
16. }
Which three lines are illegal?

1. class StaticMethods {
2. static void one() {
3. two();
4. StaticMethods.two();
5. three();

6. StaticMethods.four();
7. }
8. static void two() { }
9. void three() {
10. one();
11. StaticMethods.two();
12. four();
13. StaticMethods.four();
14. }
15. void four() { }
16. }
Which three lines are illegal?

A.
line 3

B.
line 4

C.
line 5

D.
line 6

E.
line 10

F.
line 11

G.
line 12

H.
line 13



Leave a Reply 2

Your email address will not be published. Required fields are marked *


Noname

Noname

I guess the corrupt lines are 5, 6, 13.

In line 5 we call non-static method from the static context. It is not permitted by the compiler.

In lines 5 and 13 we try to call the four() method as if it would be a static one. But it is not! So the call for this method is incorrect.

Noname

Noname

>6 or 13, sorry