logo - 刷刷题
下载APP
【简答题】

(1-4)请阅读程序,根据提示补全程序空白处,使程序能够正确运行。 class A{ } class B extends A{ } class C extends B{ } intece Info { // 在接口上定义泛型 public T getVar(); // 定义抽象方法 } class InfoImpl implements Info< 1 > { // 定义泛型接口的子类 private T var ; public InfoImpl() {} public InfoImpl(T var ) { this .setVar( var ); } public T getVar() { return this . var ; } } public class Demo4 { //show 的形参是 C 的父类 public static void show(InfoImpl< 2 > info ) { System. out .println( info ); } public static void main(String arsg []) { Info i = null ; // 声明接口对象 i = new InfoImpl< 3 >( " 孙悟空 " ); // 通过子类实例化对象 System. out .println( " 信息: " + i .getVar()); show ( new InfoImpl ()); } }

举报
参考答案:
参考解析:
.
刷刷题刷刷变学霸
举一反三

【单选题】●工作流管理系统应用中,模型实例化阶段完成(29) 。(29)

A.
企业经营过程模型建立
B.
工作流建模工具选择
C.
运行所需参数设定
D.
人机交互和应用执行

【多选题】以下泛型类public class Generic<T> {private T t; public void setT(T t) {this.t = t; }public T getT() {return t;}}下面实例化是正确的有( )。

A.
Generic<String> f2 = new Generic<>();
B.
Generic<Integer> f4 = new Generic<Number>();
C.
Generic<Number> f3 = new Generic<Integer>();
D.
Generic<String> f1 = new Generic<String>();

【多选题】对于函数模板template void foo(T t) { // Do something }的显式实例化方法有

A.
template void foo(int);
B.
template void foo(double);
C.
template void foo(long);
D.
template void foo<>(char);