2025年11月21日
Java程序设计(华东交通大学)章节测试答案
2025年11月21日
设有如下代码: class Base{} public class MyCast extends Base{ static boolean b1=false; static int i = -1; static double d = 10.1; public static void main(String argv[]){ MyCast m = new MyCast(); Base b = new Base(); //Here } } 则在 //Here处插入哪个代码将不出现编译和运行错误。 第七章单元测试 A.d =i; B.m=b; C.b1 =i; D.b=m;
设有如下代码: class Ba...
2025年11月21日
2025年11月21日
设有如下代码:interface IFace{ }class CFace implements IFace{ }class Base{ }public class ObRef extends Base{ public static void main(String argv[]){ ObRef obj = new ObRef(); Base b = new Base(); Object obj1 = new Object(); IFace obj2 = new CFace(); //Here }}则在 //Here处插入哪个代码将不出现编译和运行错误。 A.b=obj; B.obj1=obj2; C.obj=b; D.obj1=b;
设有如下代码:interface...
2025年11月21日
给出下面的不完整的类代码: class Person { String name, department; int age; public Person(String n){ name = n; } public Person(String n, int a){ name = n; age = a; } public Person(String n, String d, int a) { // doing the same as two arguments version of constructor // including assignment name=n,age=a department = d; } } 下面的哪些表达式可以加到构造方法中的”doing the same as…”处? A.this(n,a); B.this(name,age); C.name=n;age=a; D.Person(n,a);
给出下面的不完整的类代码: cl...