Given:
3. class School { 4. School getDeptName() { return new School(); } 5. } 6. class Campus extends School { 7. Campus getDeptName() { return new Campus(); } 8. // insert code here 10. }
And the following four code fragments:
I. String getDeptName(int x) { return "mktg"; } II. void getDeptName(School d) { ; } III. void getDeptName(long x) throws NullPointerException { throw new NullPointerException(); } /*from ww w. j a v a 2 s . c o m*/ IV. School getDeptName() throws NullPointerException { throw new NullPointerException(); return new School(); }
Which are true? (Choose all that apply.)
A, B, C, and E are correct.
As it stands, the code demonstrates a legal covariant return.
Fragments I, II, and III are legal overloads.
D is incorrect because fragment IV does not correctly overload the Campus.getDeptName()
method.