阿里巴巴(中国)网络技术有限公司 面试 笔试
选择题
1: 1. What will happen when you attempt to compile and run the following code?
2.
3. class Base
4.
5. {
6.
7. int i = 99;
8.
9. public void amethod()
10.
11. {
12.
13. System.out.println("Base.amethod()");
14.
15. }
16.
17. Base()
18.
19. {
20.
21. amethod();
22.
23. }
24.
25. }
26.
27. public class Derived extends Base
28.
29. {
30.
31. int i = -1;
32.
33.
34.
35. public static void main(String argv[])
36.
37. {
38.
39. Base b = new Derived();
40.
41. System.out.println(b.i);
43. b.amethod();
44. 45. } 46.
47. public void amethod()
48.
49. {
50.
51. System.out.println("Derived.amethod()");
52.
53. }
54.
55. }
56.
57. Choices:
A.Derived.amethod() -1 Derived.amethod()
B.Derived.amethod() 99
pile time error
D.Derived.amethod()
2: 1. Which is the most appropriate code snippet that can be inserted at line 18 in the follo
wing code?
2.
3. (Assume that the code is compiled and run with assertions enabled)
4.
5. 1. import java.util.*;
6.
7. 2.
8.
9. 3. public class AssertTest
10.
11. 4. {
12.
13. 5. private HashMap cctld;
14.
15. 6.
16.
17. 7. public AssertTest()
19. 8. {
20. 21. 9. cctld = new HashMap(); 22.
23. 10. cctld.put("in", "India"); 24.
25. 11. cctld.put("uk", "United Kingdom");
26.
27. 12. cctld.put("au", "Australia"); 28.
29. 13. // more code...
30.
31. 14. }
32.
33. 15. // other methods ....
34.
35. 16. public String getCountry(String countryCode)
36.
37. 17. {
38.
39. 18. // What should be inserted here?
40.
41. 19. String country = (String)cctld.get(countryCode);
42.
43. 20. return country;
44.
45. 21. }
46.
47. 22. }
A.assert countryCode != null;
B.assert countryCode != null : "Country code can not be null" ;
C.assert cctld != null : "No country code data is available";
D.assert cctld : "No country code data is available";
3:
1. What will be the result of executing the following code?
2. boolean a = true;
3. boolean b = false;
4. boolean c = true;
5. if (a == true) 6. if (b == true)
7. if (c == true) System.out.println("Some things are true in this world");
8. else System.out.println("Nothing is true in this world!");
9. else if (a && (b = c)) System.out.println("It's too confusing to tell what is true and what is false");
10. else System.out.println("Hey this won't compile");
11.
12. Choices: A.The code won't compile
B."Some things are true in this world" will be printed
C."Hey this won't compile" will be printed
D.None of these
4:A class design requires that a member variable should be accessible only by same package, which modifer word should be used?
A.protected
B.public
C.no modifer
D.private
5:Which is the main() method return of a application?
A.String
B.byte
C.char
D.void
6:在软件生命周期中,下列哪个说法是不准确的?
A.软件生命周期分为计划、开发和运行三个阶段
B.在计划阶段要进行问题焉醛和需求分析
C.在开发后期要进行编写代码和软件测试
D.在运行阶段主要是进行软件维护
7: 1. Given the following class definition: 2. class A{
3. protected int i;
4. A(int i){
5. this.i=i; 6. }
7. }
8. which of the following would be a valid inner class for this class?
9. Select valid answer:
A.class B{ }
B.class B extends A{ }
C.class B extends A{ B(){System.out.println(“i=”+i);} }
D.class B{ class A{} }
8: 1. String s=”Example String”;Which operation is not legal? A.int i=s.length();
B.s[3]=”x”;
C.String short_s=s.trim();
D.String t=”root”+s;
9:Which fragments are not correct in Java source file?
A.package testpackage; public class Test{//do something...}
B.import java.io.*; package testpackage; public class Test{// do something...}
C.import java.io.*; class Person{// do something...} public class Test{// do something...}
D.import java.io.*; import java.awt.*; public class Test{// do something...}
10: Which of the following statements are true?
A.The automatic garbage collection of the JVM prevents programs from ever running out of memory
B.A program can suggest that garbage collection be performed and force it
C.Garbage collection is platform independent
D.An object becomes eligible for garbage collection when all references denoting it are set to null.
11: 1. What results from attempting to compile and run the following code? 2.
3. public class Ternary
4. 5. {
6.
7. public static void main(String args[])
8.
9. {
10. 11. int a = 5;
12.
13. System.out.println("Value is - " + ((a < 5) ? 9.9 : 9));
14.
15. }
16.
17. }
18.
19. Choices:
A.prints: Value is - 9
pilation error
C. prints: Value is - 5
D.None of these
12:
1. Give the following java source fragement:
2. //point x
相关推荐:
- [资格考试]石油钻采专业设备项目可行性研究报告编
- [资格考试]2012-2013学年度第二学期麻风病防治知
- [资格考试]道路勘测设计 绪论
- [资格考试]控烟戒烟知识培训资料
- [资格考试]建设工程安全生产管理(三类人员安全员
- [资格考试]photoshop制作茶叶包装盒步骤平面效果
- [资格考试]授课进度计划表封面(09-10下施工)
- [资格考试]麦肯锡卓越工作方法读后感
- [资格考试]2007年广西区农村信用社招聘考试试题
- [资格考试]软件实施工程师笔试题
- [资格考试]2014年初三数学复习专练第一章 数与式(
- [资格考试]中国糯玉米汁饮料市场发展概况及投资战
- [资格考试]塑钢门窗安装((专项方案)15)
- [资格考试]初中数学答题卡模板2
- [资格考试]2015-2020年中国效率手册行业市场调查
- [资格考试]华北电力大学学习实践活动领导小组办公
- [资格考试]溃疡性结肠炎研究的新进展
- [资格考试]人教版高中语文1—5册(必修)背诵篇目名
- [资格考试]ISO9001-2018质量管理体系最新版标准
- [资格考试]论文之希尔顿酒店集团进入中国的战略研
- 全国中小学生转学申请表
- 《奇迹暖暖》17-支2文学少女小满(9)公
- 2019-2020学年八年级地理下册 第六章
- 2005年高考试题——英语(天津卷)
- 无纺布耐磨测试方法及标准
- 建筑工程施工劳动力安排计划
- (目录)中国中央空调行业市场深度调研分
- 中国期货价格期限结构模型实证分析
- AutoCAD 2016基础教程第2章 AutoCAD基
- 2014-2015学年西城初三期末数学试题及
- 机械加工工艺基础(完整版)
- 归因理论在管理中的应用[1]0
- 突破瓶颈 实现医院可持续发展
- 2014年南京师范大学商学院决策学招生目
- 现浇箱梁支架预压报告
- Excel_2010函数图表入门与实战
- 人教版新课标初中数学 13.1 轴对称 (
- Visual Basic 6.0程序设计教程电子教案
- 2010北京助理工程师考试复习《建筑施工
- 国外5大医疗互联网模式分析