Java练习题1(有答案)(11)
System.out.println(
\= \+ myCount.count); System.out.println(\= \times);
} public static void increment(Count c, int times) { c.count++; times++; } } class Count { int count; Count(int c) { count = c; } Count() { count = 1; } } 1、 101 2、 100 3、 99
4、 98 5、 0 答案 5 第 113题 Given the declaration Circle[] x = new Circle[10], which of the following statement is most accurate. 1、 x contains an array of ten int values.
2、 x contains an array of ten objects of the Circle type.
3、 x contains a reference to an array and each element in the array can hold a reference to a Circle object.
4、 x contains a reference to an array and each element in the array can hold a Circle object.
答案 3 第114题 Assume java.util.Date[] dates = new java.util.Date[10], which of the following statements are true? 1、 dates is null. 2、 dates[0] is null.
3、 dates = new java.util.Date[5] is fine, which assigns a new array to dates. 4、 dates = new Date() is fine, which creates a new Date object and assigns to dates. 答案 2 3 第 115题 Which of the following statements are true about an immutable object?
1、 The contents of an immutable object cannot be modified. 2、 All properties of an immutable object must be private.
3、 All properties of an immutable object must be of primitive types.
4、 An object type property in an immutable object must also be immutable.
5、 An immutable object contains no mutator methods. 答案 1 2 4 5 第 116题 What is the printout for the first statement in the main method?
public class Foo { static int i = 0; static int j = 0; public static void main(String[] args) { int i = 2; int k = 3; { int j = 3;
System.out.println(\ } k = i + j;
System.out.println(\ System.out.println(\ } }
1、 i + j is 5 2、 i + j is 6 3、 i + j is 22
4、 i + j is 23 答案 4 第 117题 What is the printout for the second statement in the main method? public class Foo { static int i = 0; static int j = 0; public static void main(String[] args) { int i = 2; int k = 3; { int j = 3;
System.out.println(\ } k = i + j;
System.out.println(\ System.out.println(\ } }
1、 k is 0 2、 k is 1 3、 k is 2 4、 k is 3
答案 3 第 118题 What is the printout for the third statement in the main method?
public class Foo { static int i = 0; static int j = 0; public static void main(String[] args) { int i = 2; int k = 3; { int j = 3;
System.out.println(\ } k = i + j;
System.out.println(\ System.out.println(\ } }
1、 j is 0 2、 j is 1 3、 j is 2
4、 j is 3 答案 1 第 119题 Analyze the following code:
class Circle { private double radius; public Circle(double radius) { radius = radius; } }
1、 The program has a compilation error because it does not have a main method.
2、 The program will compile, but you cannot create an object of Circle with a specified radius. The object will always have radius 0.
3、 The program has a compilation error because you cannot assign radius to radius.
4、 The program does not compile because Circle does not have a default constructor.
答案 2 第 120题 Analyze the following code: class Test { private double
i;
public
Test(double } public Test() {
System.out.println(\constructor\ public void t() {
System.out.println(\ } }
1、 this.t() may be replaced by t(). 2、 this.i may be replaced by i.
3、 this(1) must be called before System.out.println(\constructor\
4、 this(1) must be replaced by this(1.0). 答案 1 3 第 121题 Object-oriented programming allows you to derive new classes from existing classes. This is called ____________. 1、 encapsulation 2、 inheritance
3、 abstraction 4、 generalization 答案 2 第 122题 Suppose you create a class Cylinder to be a subclass of Circle. Analyze the following code: class Cylinder extends Circle { double length;
Cylinder(double radius) { Circle(radius); } }
1、 The program compiles fine, but you cannot create an instance of Cylinder because the constructor does not specify the length of the cylinder. 2、 The program has a compile error because you attempted to invoke the Circle class s constructor illegally.
3、 The program compiles fine, but it has a runtime error because of invoking the Circle class s constructor illegally. 答案 2 第 123题 Analyze the following code: import java.util.StringTokenizer; public class A extends StringTokenizer {
i)
{ this.t(); this.i = i;
}
1、 The program has a compilation error because A does not have a default constructor.
2、 The program has a compilation error because the default constructor of
A
invokes
the
default
constructor
of
StringTokenizer,
but
StringTokenizer does not have a default constructor.
3、 The program would compile fine if you add the following constructor into A:
A(String s) { }
4、 The program would compile fine if you add the following constructor into A: A(String s) { super(s); } 答案 2 4 第 124题 Analyze the following code: public class Test extends A { public static void main(String[] args) { Test t = new Test(); t.print(); } } class A { String s; A(String s) { this.s = s; } public
void
print()
{ System.out.println(s); } }
1、 The program does not compile because Test does not have a default constructor Test().
2、 The program has an implicit default constructor Test(), but it cannot be compiled, because its s …… 此处隐藏:3511字,全部文档内容请下载后查看。喜欢就下载吧 ……
相关推荐:
- [实用模板]第八章:法国“新浪潮”与“左岸派”
- [实用模板]2021年北京上半年临床医学检验技师生物
- [实用模板]SAP GUI 7.10客户端安装配置文档
- [实用模板]2001年临床执业医师资格考试综合笔试试
- [实用模板]36机场工作实用英语词汇总结
- [实用模板](一)社会保险稽核通知书
- [实用模板]安全教育主题班会材料
- [实用模板]濉溪县春季呼吸道传染病防控应急演练方
- [实用模板]长沙房地产市场周报(1.30-2.3)
- [实用模板]六年级数学上册典中点 - 图文
- [实用模板]C程序设计(红皮书)习题官方参考答案
- [实用模板]中国证监会第一届创业板发行审核委员会
- [实用模板]桥梁工程复习题
- [实用模板]2011学而思数学及答案
- [实用模板]初中病句修改专项练习
- [实用模板]监理学习知识1 - 图文
- [实用模板]小机灵杯四年级试题
- [实用模板]国贸专业毕业论文模板
- [实用模板]教育学概论考试练习题-判断题4
- [实用模板]2015届高考英语一轮复习精品资料(译林
- 00Nkmhe_市场营销学工商管理_电子商务_
- 事业单位考试法律常识
- 诚信教育实施方案
- 吉大小天鹅食品安全检测箱方案(高中低
- 房地产销售培训资料
- 高一地理必修1复习提纲
- 新概念英语第二册lesson_1_练习题
- 证券公司内部培训资料
- 小学英语时间介词专项练习
- 新世纪英语专业综合教程(第二版)第1册U
- 【新课标】浙教版最新2018年八年级数学
- 工程建设管理纲要
- 外研版 必修一Module 4 A Social Surve
- Adobe认证考试 AE复习资料
- 基于H.264AVC与AVS标准的帧内预测技术
- 《食品检验机构资质认定管理办法》(质
- ABB变频器培训课件
- (完整版)小学说明文阅读练习题及答案
- 深思洛克(SenseLock) 深思IV,深思4,深
- 弟子规全文带拼音




