下面是class Person{}中定义的方法,属于泛型方法的是( )
A. E void show(int a){}
B. T getData(){}
C. T Get(T a){}
D. T Get(E a)
查看答案
{下面程序的编译运行结果是( )class GeneralClass{T data;GeneralClass(T data){this.data = data;}public void show(E a,T b){System.out.print(a);System.out.print(b);}}public class Demo2015 {public static void main(String []args){GeneralClass sObj = new GeneralClass("hello");System.out.print(sObj.data);sObj.show(1,"2");}}}
A. 编译错误,因为sObj.show(1,"2");中两个实参的类型不一致
B. 编译错误,因为类型参数E和T代表的数据类型不一致
C. hello12
D. 编译错误,因为sObj.show(1,"2")中实参的类型与参数T指定的类型不一致
下面有关通配符描述错误的是( )
A. >类型参数可以为任意类型
B. >与
{现有类的定义如下:class Person{}class Student extends Person{}class Teacher extends Person{}class Box{}class Infor{Infor(T a){System.out.print(a);}}则下面语句错误的是( )}
A. Infor> t =new Infor("hello");
B. Infor extends Person> t1 = new Infor(new Teacher());
C. Infor super Person> t2 = new Infor
下面有关集合框架描述错误的是( )
A. 集合框架类对象存储的数据可以是任意类型的数据
B. 集合框架类对象存储的空间是变长的
C. 创建集合框架类对象必须指定空间长度
D. 集合框架类或接口都包含在java.util包中