教学文库网 - 权威文档分享云平台
您的当前位置:首页 > 文库大全 > 资格考试 >

阿里巴巴(中国)网络技术有限公司 面试 笔试

来源:网络收集 时间:2025-10-13
导读: 选择题 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.

选择题

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

3. p …… 此处隐藏:4022字,全部文档内容请下载后查看。喜欢就下载吧 ……

阿里巴巴(中国)网络技术有限公司 面试 笔试.doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.jiaowen.net/wenku/97277.html(转载请注明文章来源)
Copyright © 2020-2025 教文网 版权所有
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:78024566 邮箱:78024566@qq.com
苏ICP备19068818号-2
Top
× 游客快捷下载通道(下载后可以自由复制和排版)
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能出现无法下载或内容有问题,请联系客服协助您处理。
× 常见问题(客服时间:周一到周五 9:30-18:00)