ImageVerifierCode 换一换
格式:DOCX , 页数:26 ,大小:26.98KB ,
资源ID:3746450      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/3746450.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(测试无答案.docx)为本站会员(b****3)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

测试无答案.docx

1、测试无答案Questions 1. What will happen when you attempt to compile and run the following code? public class Staticstaticint x = 5; static int x,y;public static void main(String args) x-; myMethod(); System.out.println(x + y + +x); public static void myMethod()y = x+ + +x; Choices:a. Compiletime error b.

2、 prints : 1 c. prints : 2 d. prints : 3 e. prints : 7 f. prints : 8 2. Given the following code, what will be the output? class Valuepublic int i = 15; public class Testpublic static void main(String argv) Test t = new Test();t.first(); public void first() int i = 5; Value v = new Value();v.i = 25;s

3、econd(v, i); System.out.println(v.i); public void second(Value v, int i)i = 0; v.i = 20;Value val = new Value(); v = val; System.out.println(v.i + + i); Choices:a. 15 0 20b. 15 0 15 c. 20 0 20 d. 0 15 20 3. What will happen when you attempt to compile and run the following code? class MyParent int x

4、, y;MyParent(int x, int y)this.x = x;this.y = y;public int addMe(int x, int y)return this.x + x + y + this.y;public int addMe(MyParent myPar)return addMe(myPar.x, myPar.y); class MyChild extends MyParentint z;MyChild (int x, int y, int z)super(x,y);this.z = z;public int addMe(int x, int y, int z)ret

5、urn this.x + x + this.y + y + this.z + z;public int addMe(MyChild myChi)return addMe(myChi.x, myChi.y, myChi.z);public int addMe(int x, int y)return this.x + x + this.y + y; public class MySomeOnepublic static void main(String args)MyChild myChi = new MyChild(10, 20, 30);MyParent myPar = new MyParen

6、t(10, 20);int x = myChi.addMe(10, 20, 30);int y = myChi.addMe(myChi);int z = myPar.addMe(myPar);System.out.println(x + y + z); Choices:a. 300 b. 240 c. 120 d. 180 e. Compilation error f. None of the above 4. What will be the result of executing the following code? 1. boolean a = true;2. boolean b =

7、false;3. boolean c = true;4. if (a = true)5. if (b = true)6. if (c = true) System.out.println(Some things are true in this world);7. else System.out.println(Nothing is true in this world!);8. else if (a & (b = c) System.out.println(Its too confusing to tell what is true and what is false);9. else Sy

8、stem.out.println(Hey this wont compile); Choices:a. The code wont compileb. Some things are true in this world will be printedc. Hey this wont compile will be printedd. None of these 5. What will happen when you attempt to compile and run the following code? interface MyInterface public class MyInst

9、anceTest implements MyInterfacestatic String s; public static void main(String args)MyInstanceTest t = new MyInstanceTest(); if(t instanceof MyInterface)System.out.println(I am true interface);else System.out.println(I am false interface); if(s instanceof String)System.out.println(I am true String);

10、else System.out.println(I am false String); Choices:a. Compiletime error b. Runtime error c. Prints : I am true interface followed by I am true String d. Prints : I am false interface followed by I am false String e. Prints : I am true interface followed by I am false String f. Prints : I am false i

11、nterface followed by I am true String 6. What results from attempting to compile and run the following code? public class Ternarypublic 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. prints: Value is - 5 c. Compilation erro

12、r d. None of these 7. In the following pieces of code, A and D will compile without any error. True/False? A: StringBuffer sb1 = abcd; B: Boolean b = new Boolean(abcd); C: byte b = 255; D: int x = 0x1234; E: float fl = 1.2; Choices:a. Trueb. False 8. Considering the following code, Which variables m

13、ay be referenced correctly at line 12? 1.public class Outer2.3.public int a = 1;4.private int b = 2;5.public void method(final int c)6.7.int d = 3;8.class Inner9.10.private void iMethod(int e)11. 12. 13.14.15.16. Choices:a. a b. bc. cd. de. e 9. What will be the result of executing the following cod

14、e? 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 be printed 11 times. b. 100 will be printed 10 times and then

15、there will be a runtime exception. c. The code will not compile because the variable i cannot be declared twice within the main() method. d. The code will not compile because the variable j cannot be declared twice within the switch statement.e. None of these. 10. What will happen when you attempt t

16、o compile and run the following code? class MyThread extends Threadpublic void run()System.out.println(MyThread: run(); public void start()System.out.println(MyThread: start(); class MyRunnable implements Runnablepublic void run()System.out.println(MyRunnable: run(); public void start()System.out.pr

17、intln(MyRunnable: start(); public class MyTest public static void main(String args)MyThread myThread = new MyThread();MyRunnable myRunnable = new MyRunnable();Thread thread = new Thread(myRunnable);myThread.start();thread.start(); Choices:a. Prints : MyThread: start() followed by MyRunnable:run()b.

18、Prints : MyThread: run() followed by MyRunnable:start()c. Prints : MyThread: start() followed by MyRunnable:start()d. Prints : MyThread: run() followed by MyRunnable:run()e. Compile time error f. None of the above 11. Given the code below, and making no other changes, which access modifiers (public,

19、 protected or private) can legally be placed before myMethod() on line 3? If line 3 is left as it is, which keywords can legally be placed before myMethod on line 8? 1.class HumptyDumpty2.3.void myMethod() 4.5.6.class HankyPanky extends HumptyDumpty7.8.void myMethod() 9. Choices:a. private or nothin

20、g(i.e. leaving it as it is) on line 3. Nothing(i.e. leaving it as it is) or protected or public on line 8.b. public or protected on line 3. private or nothing(i.e. leaving itas it is) on line 8. c. nothing(i.e. leaving it as it is) or protected or public on line 3. private or nothing(i.e. leaving it

21、 as it is) on line 8.d. None of the above. 12. What will be the result of executing the following code? / Filename; SuperclassX.javapackage packageX; public class SuperclassXprotected void superclassMethodX()int superclassVarX; / Filename SubclassY.java1.package packageX.packageY;2.3.public class Su

22、bclassY extends SuperclassX4.5.SuperclassX objX = new SubclassY();6.SubclassY objY = new SubclassY();7.void subclassMethodY()8.9.objY.superclassMethodX();10.int i;11.i = objY.superclassVarX;12.13. Choices:a.Compilation error at line 5b. Compilation error at line 9c. Runtime exception at line 11d. No

23、ne of these 13. Consider the class hierarchy shown below: - class FourWheeler implements DrivingUtilitiesclass Car extends FourWheelerclass Truck extends FourWheelerclass Bus extends FourWheelerclass Crane extends FourWheeler- Consider the following code below:1.DrivingUtilities du;2.FourWheeler fw;

24、3.Truck myTruck = new Truck();4.du = (DrivingUtilities)myTruck;5.fw = new Crane();6.fw = du; Which of the statements below are true? Choices:a. Line 4 will not compile because an interface cannot refer to an object. b. The code will compile and run. c. The code will not compile without an explicit c

25、ast at line 6, because goingdown the hierarchy without casting is not allowed.d.The code at line 4 will compile even without the explicit cast. e.The code will compile if we put an explicit cast at line 6 but will throw an exception at runtime. 14. What results from the following code? 1.class MyCla

26、ss2.3.void myMethod(int i) System.out.println(int version);4.void myMethod(String s) System.out.println(String version);5.public static void main(String args)6.7.MyClass obj = new MyClass();8.char ch = c;9.obj.myMethod(ch);10.11. Choices:a. Line 4 will not compile as void methods cant be overridden.

27、b. An exception at line 9.c. Line 9 will not compile as there is no version of myMethod which takes a char as argument.d. The code compiles and produces output: int version.e. The code compiles and produces output: String version. 15. What is the result when you compile and run the following code? public class ThrowsDemo static void throwMethod() System.out.println(Inside throwMethod.); throw new IllegalAccessException(demo); public static void main(String args) try throwMethod(); catch (IllegalAccessException e) System.out.println(Caught + e); Choices:a. Compilation errorb. Runt

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1