首页题目详情

以下哪种情况是正确使用super关键字的示例?

题目配图
A.List<? super Integer> list = new ArrayList<>();
B.List<? extends String> list = new ArrayList<>();
C.List<String super Integer> list = new ArrayList<>();
D.List<String extends Integer> list = new ArrayList<>();

优质解答

答案

A

解析

super关键字用于指定类型参数的下界,它允许类型参数为指定类型的父类或超类。例如,List<? super Integer>表示可以接受Integer及其父类的列表。

查看答案和解析

支付 ¥0.1 即可查看此题答案和详细解析

低至 ¥0.1 起

面向对象程序设计单选题中等AI生成