Java OCA OCP Practice Question 3283

Question

Which statements are true about the classes SupA, SubB and SubC?:

class SupA<T> {
   public List<?> fuddle() { return null; }
   public List scuddle(T t) { return null; }
}

class SubB<U> extends SupA<U> {
   public List fuddle() { return null;}
   public List<?> scuddle(U t) { return null; }
}

class SubC<V> extends SupA<V> {
   public List<V> fuddle() { return null;}
   public List<? extends Object> scuddle(V t) { return null; }
}

Select the four correct answers.

(a) Class SubB will not compile.
(b) Class SubC will not compile.
(c) Class SubB will compile.
(d) Class SubC will compile.
(e) Class SubB overloads the methods in class SupA.
(f) Class SubC overloads the methods in class SupA.
(g) Class SubB overrides the methods in class SupA.
(h) Class SubC overrides the methods in class SupA.


(c), (d), (g), (h)

Note

The method header signature of the corresponding methods are the same after erasure, i.e. List fuddle() and List scuddle(Object).

The return type of overriding methods can be a raw type or a parameterized type.




PreviousNext

Related