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

更新时间:2023-08-29 18:34:01 阅读量: 教育文库 文档下载

说明:文章内容仅供预览,部分内容可能不全。下载后的文档,内容与下面显示的完全一致。下载之前请确认下面内容是否您想要的,是否完整无缺。

选择题

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

http://www.77cn.com.cnpile 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

http://www.77cn.com.cnpilation error

C. prints: Value is - 5

D.None of these

12:

1. Give the following java source fragement:

2. //point x

3. public class Interesting{

4. //do something 5. }

6. Which statement is correctly Java syntax at point x? A.public class MyClass{//do other thing…}

B.static int PI=3.14

C.class MyClass{//do something…}

D.none

13: 1. What will happen when you attempt to compile and run the following code?

2.

3. (Assume that the code is compiled and run with assertions enabled.)

4.

5. public class AssertTest{

6.

7. public void methodA(int i){

8.

9. assert i >= 0 : methodB();

10.

11. System.out.println(i);

12.

13. }

14.

15. public void methodB(){

16.

17. System.out.println("The value must not be negative");

18.

19. }

20.

21. public static void main(String args[]){

22.

23. AssertTest test = new AssertTest();

24.

25. test.methodA(-10);

26.

27. }

28.

29. }

A.it will print -10

B.it will result in AssertionError showing the message-“the value must not be negative”.

C.the code will not compile.

D.None of these.

14: 1. Give the code fragment:

2. if(x>4){ 3. System.out.println(“Test 1”);}

4. else if (x>9){ 5. System.out.println(“Test 2”);}

6. else {

7. System.out.println(“Test 3”);}

8. Which range of value x would produce of output “Test 2”?

A.x<4

B.x>4

C.x>9

D.None

简答题 15:将某个文件从一个目录拷贝到另一个目录下(不能用C/C++中的函数或类)。

16:集群的优点和缺点?

17:编一个程序求质数的和例如F(7)=1+3+5+7+11+13+17=58

18:假设现有一个单向的链表,但是只知道只有一个指向该节点的指针p,并且假设这个节点不是尾节点,试编程实现删除此节点。

19:建立一个链表,每个结点包括:学号、姓名、性别、年龄,输入一个学号,如果链表中的结点包括该学号,则输出该结点内容后,并将其结点删去。

20:C/C++源代码中,检查花括弧“(”与 “)”,“{”与“}”)是否匹配,若不匹配,则输出不匹配花括弧所在的行与列。

21:请设计一个Java程序,程序中要进行数组操作和除法操作,要求对所设计的程序可能出现的异常进行处理。

22:Hashtable和HashMap的异同。

23:Write the function strend(s,t) , which returns 1 if the string t occurs at the end of the string s , and zero otherwise.

24:请说出你所知道的线程同步的方法。

25:Is Tomcat faster than serving static HTML pages than Apache httpd?

本文来源:https://www.bwwdw.com/article/c42i.html

微信扫码分享

《阿里巴巴(中国)网络技术有限公司 面试 笔试.doc》
将本文的Word文档下载到电脑,方便收藏和打印
推荐度:
点击下载文档
下载全文
范文搜索
下载文档
Top