Java---Which four statements are true
来源:互联网 发布:redis数据库设计java 编辑:程序博客网 时间:2024/06/04 21:15
class A {}
class B extends A {}
class C extends A {}
class D extends B {}
答案:A、C、D、G
class B extends A {}
class C extends A {}
class D extends B {}
Which four statements are true ?
A:The type List<A>is assignable to List.
B:The type List<B>is assignable to List<A>.
C:The type List<Object>is assignable to List<?>.
D:The type List<D>is assignable to List<?extends B>.
E:The type List<?extends A>is assignable to List<A>.
F:The type List<Object>is assignable to any List reference.
G:The type List<?extends B>is assignable to List<?extends A>.
解析:本题考查的是泛型通配符的问题。
?:表示任意类型,如果没有明确,那么就是Object以及任意的java类了;
? extends E:向下限定,E及其子类;
? super E:向上限定,E及其父类。
做这道题目的时候,只需要看尖括号<>里面的内容,明确点和范围的概念。规则如下:
(1)如果尖括号<>里面是一个类,那么代表的就是一个点,例如:List<A>、List<B>、List<C>等;
(2)如果尖括号<>里面有问号,那么代表一个范围,<? extends A>代表小于等于A的范围,<? super A>代表大于等于A的范围,<?>代表全部范围;
(3)尖括号<>里的所有点相互赋值都是错,除非是俩相同的点;
(4)尖括号小范围赋值给大范围是正确的,大范围赋值给小范围是错误的,如果某点包含在某个范围里,那么可以赋值,否则不能赋值;
(5)List<?>和List是相等的,都代表最大范围;
(6)List既是点,也是范围,当表示范围时,是最大范围。
0 0
- Java---Which four statements are true
- 133. Which three statements are true? (Choose three.)
- 27.Which two statements are true regarding tables?
- 28.Which two statements are true regarding constraints?
- 29.Which two statements are true regarding constraints?
- 35.Which two statements are true regarding constraints? (Choose two.)
- 38.Which two statements are true regarding views? (Choose two.)
- 41.Which two statements are true regarding views? (Choose two.)
- 42.Which three statements are true regarding views? (Choose three.)
- 48.Which two statements are true regarding indexes? (Choose two.)
- 133.Which two statements are true regarding subqueries? (Choose two.)
- 135.Which three statements are true regarding subqueries? (Choose three.)
- 175.Which two statements are true regarding savepoints? (Choose two.)
- 50.Which two statements are true about alerts? (Choose two.)
- 65.Which two statements are true about checkpointing? (Choose two.)
- 130.Which two statements are true regarding listeners? (Choose two.)
- Which three statements are true regarding the functioning of the Autotask Background Process (ABP)?
- 053-4 Which two statements about the SQL Management Base (SMB) are true? (Choose two.)
- 使用Base64编码对图片进行编码与显示
- Activity
- 1001. 害死人不偿命的(3n+1)猜想 (15)
- bzoj4102(基于图的神dp)
- 微信小程序(应用号)开发你一定要知道的一些细节
- Java---Which four statements are true
- 缓冲区溢出
- LeetCode 148. Sort List
- jquery 删除动态创建的table中的tr
- 初识STL——set,multiset,map,multimap
- 写好自己的模板方法,以后要做的就是对于模板方法进行具体化了
- PHP入门
- ehcache2.5后hibernate多SessionFactory报错的解决
- Service