9 mar 2010

Overriding i overloading

Following code fragment is given (Java 5):

1: class Human {
2:
Human getIt() {
3:
return this;
4:
}
5:
}
6:
7:
class Worker extends Human {
8:
// insert a single method here
9:
}

Which of the following methods would compile if inserted at line 8

Human getIt() { return this; }
Worker getIt() { return this; }
Object getIt() { return this; }
int getIt() { return 1; }
int getIt(int x) { return 1; }
Object getIt(int x) { return this; }


Brak komentarzy:

Prześlij komentarz