《搜狐公司 java高级工程师笔试题》由会员分享,可在线阅读,更多相关《搜狐公司 java高级工程师笔试题(7页珍藏版)》请在金锄头文库上搜索。
1、1: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 2:What will happen when you attempt to compile and run the following code? public class Staticstaticint x = 5; static int x,y;pub
2、lic static void main(String args)x-;myMethod();System.out.println(x + y + +x); public static void myMethod()y = x+ + +x; Choices:A.prints : 2 B.prints : 3 C.prints : 7 D.prints : 8 3:What will be the result of executing the following code? public static void main(String args)char digit = a;for (int
3、i = 0; i 10; i+)switch (digit)case x :int j = 0;System.out.println(j);default :int j = 100;System.out.println(j);int i = j;System.out.println(i); 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 w
4、ill not compile because the variable j cannot be declared twice within the switch statement. D.None of these. 4: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.impo
5、rt java.io.*; class Person/ do something. public class Test/ do something. D.import java.io.*; import java.awt.*; public class Test/ do something. 5:下述程序代码中有语法错误的行是( ) 。int i,ia10,ib10; /*第一行 */for (i=0;i=9;i+) /*第 2 行*/iai=0; /*第 3 行*/ib=ia; /*第 4 行*/A.第 1 行 B.第 2 行 C.第 3 行 D.第 4 行 6: Which of the
6、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 wh
7、en all references denoting it are set to null. 7:Select valid identifier of Java:A.%passwd B.3d_game C.$charge D.this 8:Math.round(-11.5)等於多少? A.-11 B.-12 C.-11.5 D.none 9:What results from attempting to compile and run the following code? public class Ternarypublic static void main(String args)int
8、a = 5;System.out.println(Value is - + (a 5) ? 9.9 : 9); Choices:A.prints: Value is - 9 B.Compilation error C. prints: Value is - 5 D.None of these 10:Which is the main() method return of a application? A.String B.byte C.char D.void 11:In the following code, which is the earliest statement, where the
9、 object originally held in e, may be garbage collected:1.public class Test 2. public static void main (String args ) 3. Employee e = new Employee(Bob, 48); 4. e.calculatePay(); 5. System.out.println(e.printDetails(); 6. e = null; 7. e = new Employee(Denise, 36); 8. e.calculatePay(); 9. System.out.pr
10、intln(e.printDetails(); 10. 11.Only One: A.Line 10 B.Line 11 C.Line 7 D.Line 8 12:Give this class outline:class Exampleprivate int x;/rest of class bodyAssuming that x invoked by the code java Example, which statement can made x be directly accessible in main() method of Example.java?A.Change privat
11、e int x to public int x B.change private int x to static int x C.Change private int x to protected int x D.change private int x to final int x 13:以下的 C 程序代码片段运行后 C 和 d 的值分别是多少 Int a =1,b =2; Int c,d; c =(a d =(a A.0,0 B.0,1 C.1,0 D.1,1 14:假定 a 和 b 为 int 型变量,则执行下述语句组后,b 的值为 a=1; b=10; do b-=a; a+; wh
12、ile (b-0); A.9 B.-2 C.-1 D.8 15:Math.round(11.5)等於多少? A.11 B.12 C.11.5 D.none 简答题 16:Hashtable 和 HashMap 的异同。 17:用 100 元钱买 100 支笔,其中钢笔 3 元 / 支,圆珠笔 2 元 / 支,铅笔 0.5 元 / 支,问钢笔、圆珠笔和铅笔可以各买多少支 ? 18:tomcat 中,什么是 DefaultServlet?他的功能是什么? 19:一个类只有实现了 Serializable 接口或者 Externalizable 接口,它的对象才可以被序列化。请问,这两种序列化机制有何区别? 20:char 型变量中能不能存贮一个中文汉字? 为什么? 21:字符串 A 是由 n 个小写英文字母(a z)构成的,定义为 char An。你能用更少的空间表示这个字符串吗?请写出从 char An到你的新的储存格式的转换函数。 22:用递归法将一个整数 n 转换成字符串(例如输入 4679,应输出字符串 “4679”),n 为不确定数,可以是位数不超过 5,且数值在-3276832767 之间和任意整数。 23:同步和异步有和异同,在什么情况下分别使用他们?举例说明。 文章来源:笔试网 专业的笔试、面试资料搜索网站