《2022年搜狐公司_JAVA高级工程师笔试题及答案 .pdf》由会员分享,可在线阅读,更多相关《2022年搜狐公司_JAVA高级工程师笔试题及答案 .pdf(8页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。
1、1:A class design requires that a member variable should be accessible only by same package, which modifer word should be used? A A.protected B.public C.no modifer D.private 2: What will happen when you attempt to compile and run the following code? B public class Static static int x = 5; static int
2、x,y; public static void main(String args) x-; myMethod(); System.out.println(x + y + +x); public static void myMethod() y = x+ + +x; 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 1 页,共 8 页 - - - - - - - - - Choices: A.prints : 2 B.prints : 3 C.prints : 7 D.prints :
3、8 3: What will be the result of executing the following code? public static void main(String args) char digit = a; for (int 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 b
4、e 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. 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - -
5、 - - 第 2 页,共 8 页 - - - - - - - - - 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.import java.io.*; class Person/ do something. public class Tes
6、t/ 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 following statements are true? A.The automatic garbag
7、e 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: Sel
8、ect valid identifier of Java: A.%passwd B.3d_game C.$charge D.this 8:Math.round(-11.5) 等於多少 ? A.-11 B.-12 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 3 页,共 8 页 - - - - - - - - - C.-11.5 D.none 9: What results from attempting to compile and run the following code?
9、public class Ternary public static void main(String args) int 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:
10、In the following code, which is the earliest statement, where the object originally held in e, may be garbage collected: 1.public class Test 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 4 页,共 8 页 - - - - - - - - - 2. public static void main (String args ) 3. Employ
11、ee 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.println(e.printDetails(); 10. 11. Only One: A.Line 10 B.Line 11 C.Line 7 D.Line 8 12: Give this class outline: class Example pri
12、vate int x; /rest of class body Assuming that x invoked by the code java Example, which statement can made x be directly accessible in main() method of Example.java? A.Change private 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 priva
13、te int x to final int x 13:以下的 C程序代码片段运行后C和 d 的值分别是多少Int a =1,b =2; 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 5 页,共 8 页 - - - - - - - - - Int c,d; c =(a&b)&a; d =(a&b)&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+; while
14、 (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 元 / 支,问钢笔、圆珠笔和铅笔可以各买多少支? publicvoid math() for ( int i = 0 ; i 100/3; i+) for ( int j = 0; j 100/2; j+) 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - -
15、- - - - - - - - - 名师精心整理 - - - - - - - 第 6 页,共 8 页 - - - - - - - - - for ( int m = 0; m 100/(0.5);m+) if (i*3) + (j*2) + (m*(0.5) = 100) System.out .println(pen: + i + gun: + j + pencial: + m); 18:tomcat 中,什么是DefaultServlet ?他的功能是什么?19:一个类只有实现了Serializable 接口或者Externalizable 接口,它的对象才可以被序列化。请问,这两种序列化
16、机制有何区别?20:char 型变量中能不能存贮一个中文汉字?为什么 ? 21:字符串 A 是由 n 个小写英文字母(a z)构成的,定义为char An。你能用更少的空间表示这个字符串吗?请写出从char An到你的新的储存格式的转换函数。char A = a, b, c; byte B = newbyteA.length; for ( int i = 0; i A.length; i+) Bi = (byte)Ai; 22:用递归法将一个整数n 转换成字符串 (例如输入4679,应输出字符串 “4679”),n 为不确定数,可以是位数不超过5,且数值在 -3276832767 之间和任意整
17、数。publicvoid convert(int i) int x; x = i /10; if (x != 0) convert(x); 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 7 页,共 8 页 - - - - - - - - - System.out .print(i % 10); 23:同步和异步有和异同,在什么情况下分别使用他们?举例说明。文章来源:笔试网 专业的笔试、面试资料搜索网站名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 8 页,共 8 页 - - - - - - - - -