博彦科技上海分公司 赴阿里巴巴资深JAVA开发工程师面试题

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

选择题
1:
1. Give the code fragment:
2. if(x>4){
3. System.out.println(“Test1”);}
4. else if (x>9){
5. System.out.println(“Test2”);}
6. else {
7. System.out.println(“Test3”);}
8. Which range of value x would produce of output “Test2”?
A.x<4
B.x>4
C.x>9
D.None
2:
1. 下述程序代码中有语法错误的行是()。

2. int i,ia[10],ib[10]; /*第一行*/
3. for (i=0;i<=9;i++) /*第2行*/
4. ia[i]=0; /*第3行*/
5. ib=ia; /*第4行*/
A.第1行
B.第2行
C.第3行
D.第4行
3:
1. public class OuterClass {
2. private double d1 = 1.0;
3. //insert code here
4. }
5. You need to insert an inner class declaration at line 3. Which two inner class declarati
ons are
6. valid?
A.class InnerOne{ public static double methoda() {return d1;} }
B.public class InnerOne{ static double methoda() {return d1;} }
C.private class InnerOne{ double methoda() {return d1;} }
D.static class InnerOne{ protected double methoda() {return d1;} } 4:
1. Give the following java class:
2. public class Example{
3. static int x[]=new int[15];
4. public static void main(String args[]){
5. System.out.println(x[5]);
6. }
7. }
8. Which statement is corrected?
A.When compile, some error will occur.
B.When run, some error will occur.
C.Output is zero.
D.Output is null.
5:
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{} }
6: 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.
7:Which statements about Java code security are not true?
A.The bytecode verifier loads all classes needed for the execution of a program.
B.Executing code is performed by the runtime interpreter.
C.At runtime the bytecodes are loaded, checked and run in an interpreter.
D.The class loader adds security by separating the namespaces for the classes of the local file system from those imported from network sources.
8:
1. The following code is entire contents of a file called Example.java,causes precisely on
e error during compilation:
2. class SubClass extends BaseClass{
3. }
4. class BaseClass(){
5. String str;
6. public BaseClass(){
7. System.out.println(“ok”);}
8. public BaseClass(String s){
9. str=s;}}
10. public class Example{
11. public void method(){
12. SubClass s=new SubClass(“hello”);
13. BaseClass b=new BaseClass(“world”);
14. }
15. }
16.
17. Which line would be cause the error?
A.9
B.10
C.11
D.12
9:
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 wh
at 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
10:在下述选项时,没有构成死循环的程序是
A.int i=100 while (1) { i=i%100+1; if (i>100) break; }
B.for (;;);
C.int k=1000; do { ++k; }while(k>=10000);
D.int s=36; while (s);--s;
11:Which code fragments would correctly identify the number of arguments passed via command line to a Java application, exclude the name of the class that is being invoke.
A.int count = args.length;
B.int count = args.length-1;
C.int count=0; while(args[count]!=null) count++;
D.int count=0;while (!(args[cou nt].equals(“”))) count++;
12:假定a和b为int型变量,则执行下述语句组后,b的值为
a=1;
b=10;
do
{
b-=a;
a++;
} while (b--<0);
A.9
B.-2
C.-1
D.8
13:
1. What will happen when you attempt to compile and run the following code?
2.
3. int Output = 10;
4.
5. boolean b1 = false;
6.
7. if((b1 == true) && ((Output += 10) == 20))
8.
9. {
10.
11. System.out.println("We are equal " + Output);
12.
13. }
14.
15. else
16.
17. {
18.
19. System.out.println("Not equal! " + Output);
20.
21. }
22.
23. Choices:
pilation error, attempting to perform binary comparison on logical data type
pilation and output of "We are equal 10".
pilation and output of "Not equal! 20".
pilation and output of "Not equal! 10".
14:鉴于Java的特点,它最适合的计算环境是
A.并行计算环境
B.分布式计算环境
C.高强度计算环境
D.开放式计算环境
15:
1. What will be the result of executing the following code?
2.
3. public static void main(String args[])
4. {
5. char digit = 'a';
6. for (int i = 0; i < 10; i++)
7. {
8. switch (digit)
9. {
10. case 'x' :
11. {
12. int j = 0;
13. System.out.println(j);
14. }
15. default :
16. {
17. int j = 100;
18. System.out.println(j);
19. }
20. }
21. }
22. int i = j;
23. System.out.println(i);
24. }
25.
26. Choices:
A.100 will be printed 11 times.
B.The code will not compile because the variable i cannot be declared twice within the main() method.
C.The code will not compile because the variable j cannot be declared twice within the switch statement.
D.None of these.
简答题
16:应用服务器与WEB SERVER的区别?
17:插入一个节点到一个有序链表。

18:Hashtable和HashMap的异同。

19:什么是序列化?什么是反序列化?为什么要序列化对象?
20:序列中的“中值记录”指的是:如果将此序列排序之后,它是第n/2个记录。

试写出一个求中值记录的算法。

21:正向最大匹配分词,怎么做最快?
22:有一篇英文文章(也就是说每个单词之间由空格分隔),请找出“csdn”着个单词出现的次数,要求效率最高,并写出算法的时间级。

23:session和cache的区别是什么。

24:String是最基本的数据类型吗?
25:tomcat中用来编译JSP页面的是哪个类,或者哪个模块?。

相关文档
最新文档