Skip to content

Question 23 I think E is also correct #10

@davidmrhodes

Description

@davidmrhodes

Question 23
Generics
Given the following family hierarchy and variable declarations, which statements compile without error?
import java.util.*;
class Grandparent {}
class Parent extends Grandparent {}
class Child extends Parent {}
class Family {
List<? super Grandparent> ancestors = null;
List<? extends Child> descendants = null;
}
A.ancestors.add(new Grandparent()); ancestors.add(new Parent()); ancestors.add(new Child());
B.descendants.add(new Child()); descendants.add(new Parent());
C.Grandparent g = ancestors.get(0);
D.Parent p = ancestors.get(0);
E.Child c = descendants.get(0);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions