lunedì 1 aprile 2013

Q115


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. }

A.
line 3

B.
line 4

C.
line 5

D.
line 6

E.
line 10

F.
line 11

G.
line 12

H.
line 13


Risposta C , D e H:
Tutte le invocazioni a metodi non statici dentro metodi statici falliscono :

class StaticMethods {

       static void one() {

             two();

             StaticMethods.two();

             three();

             StaticMethods.four();

       }

 

       static void two() {

       }

 

       void three() {

             one();

             StaticMethods.two();

             four();

             StaticMethods.four();

       }

 

       void four() {

       }

}

 


 

Nessun commento:

Posta un commento