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

加入VIP,免费下载
 

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

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

下载须知

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

版权提示 | 免责声明

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

重载和覆盖.docx

1、重载和覆盖1. Methods and varibles that do the background work of a class are known as implementation details. The implementation details encapsulated class should be given which access? c A. Public B. The default C. Private /*/ D. Protected E. It does not matter 2. Which of the following is not a benefit

2、 of encapsulation? A. Clarity of code B. Code efficiency C. The ability to add funtionality later on D. Modification requires less coding changes 3. Given: 1. public class Rectangle 2. 3. 4. public class Square extends Rectangle 5. What is the relationship between Rectangle and Square? b /*/ A. has

3、a B. is a C. Its both an is a and has a relationship. D. The relationship is neither an is a or a has a relationship. 4. Given: 1. public class Vehicle 2. private Engine theEngine; 3. 4. 5. public class Engine 6. What is the relationship between Vehicle and Engine? a /*/ A. has a B. is a C. Its both

4、 an is a and has a relationship. D. The relationship is neither an is a or a has a relationship. 5. Given: 1. public interface Moveable 2. public void moveObject(); 3. 4. 5. public class Bitmap implements Moveable 6. public void moveObject() 7. /body omitted 8. 9. What is the relationship between Mo

5、vable and Bitmap? b A. has a B. is a C. Its both an is a and has a relationship. D. The relationship is neither an is a nor a has a relationship. 6. Given: 1. class SuperTest 2. public double getNumber() 3. return Math.random() * 100; 4. 5. 6. 7. class Test extends SuperTest 8. public int getNumber(

6、) 9. return (int) (Math.random() * 100); 10. 11. public static void main(String args) 12. Test t = new Test(); 13. System.out.println(t.getNumber(); 14. 15. Which of these results could occur from this code? (Choose all that apply) f /*/ A. 59 B. 34.234 C. 134.234 D. 134 E. 100 F. This code will not

7、 compile. 7. Given: 1. class SuperTest 2. public double getNumber() 3. return Math.random() * 100; 4. 5. 6. 7. class Test extends SuperTest 8. public int getNumber(int max) 9. return (int) (Math.random() * max); 10. 11. 12. public Integer getNumber(int max) 13. int temp = (int) (Math.random() * max)

8、; 14. return new Integer(temp); 15. 16. 17. public static void main(String args) 18. Test t = new Test(); 19. System.out.println(t.getNumber(); 20. 21. Which of these statements is true? b A. The code will not compile correctly because line 19 is trying to call a method that does not exist for the c

9、lass Test. B. The code does not compile because of line 12 C. The code does not compile because of line 14 D. There is no ambiguity as to the reutrn type in line 12; therefore, this code will compile and output a double value greater than or equal to 0 and less than 100. E. This code will not compil

10、e because the getNumber() methods in the Test class must all have return types of double. 8. Given: 1. public class A 2. public static void main(String args) 3. new A().printResult(1, abc, 4); 4. 5. private void printResult(int a, long b, int c) 6. System.out.println(a + b + c); 7. 8. private void p

11、rintResult(long a, String b, int c) 9. System.out.println(a + b + c); 10. 11. Which of these statements is true? b A. The code will not compile correctly because a long and a String may not be added together in line 9. B. The code will compile and run and will display 1abc4 in the standard output. B

12、. The code will compile and run and will display 11234 in the standard output. D. The code will compile and will throw a NumberFormatException.9. When a subclass method has the same name, parameter list, and return type as a method in the parent class, this method is said to be what? d A. Extended B

13、. Overloaded C. Overextended D. Overridden /*/ 10. Which of the following must match exactly for overloaded methods to compile correclty? (Choose that all apply) d A. The parameter list B. The return type C. The exception thrown D. None of the above 11. Given: 1. public class Test 2. public static v

14、oid main(String args) 3. new Test().foo(1, 2); 4. 5. private void foo(int a, int b) 6. System.out.println(int); 7. 8. private void foo(long a, int b) 9. System.out.println(long); 10. 11. What will happen when you compile and run this program? a A. The code will compile and run, and display int. B. T

15、he code will compile and run, and display long. C. The code will not compile. D. The code will compile, but throw a runtime exception when executed. 12. Given: 1. public class Parent 2. public void execute() throws Exception 3. / body omitted 4. 5. 6. public class Child extends Parent 7. private voi

16、d execute() throws ClassCastException 8. / body omitted 9. 10. What will happen when you compile this program? a A. The program will compile successfully. B. The program will not compile because the execute() in the subclass throws a different exception than in the parent class. C. The program will

17、not compile because the execute() in the subclass has less accessibility than in the parent class. D. The program will not compile because the execute() in the subclass has less accessibliity and throws a different exception than in the parent class. 13. Given: 1. public class A 2. public void baz()

18、 3. System.out.println(A); 4. 5. 6. public class B extends A 7. public static void main(String args) 8. A a = new B(); 9. a.baz(); 10. 11. public vod baz() 12. System.out.println(B); 13. 14. What will happen when you compile and run this program? b A. The program compiles, runs, and display A in the

19、 standard output. B. The program compiles, runs, and display B in the standard output. C. The program compiles, but throws a runtime exception. D. The program does not compile. 14. Given: 1. public class A 2. public static void main(String args) 3. new A().baz(1, 2); 4. 5. private void baz(int a, in

20、t b) 6. System.out.println(baz); 7. 8. private void foo(int a, int b) 9. System.out.println(first); 10. 11. private boolean foo(int a, int b) 12. System.out.println(second); 13. return true; 14. 15. Which of the following statements is true? A. The program compiles, runs, and displays first in the s

21、tandard output. B. The program compiles, runs, and displays second in the standard output. C. The program compiles, runs, and displays baz in the standard output. D. The program does not compile. 15. Given: 1. public class Test 2. protected void start() throws ClassCastException 3. / body omitted 4.

22、 5. 6. 7. public class Child extends Test 8. public void start() throws Exception 9. / body omitted 10. 11. What will happen when you compile this program? A. The program will compile successfully. B. The program will not compile because the start() in the subclass throws a different exception than

23、in the parent class. C. The program will not compile because the start() in the subclass is public, whereas it is protected in the parent class. D. The program will not compile because the start() in the subclass has different accessibility and throws a different exception than in the parent class.1

24、6. When two or more methods in the same class have the same name, they are said to be what? A. An implementation detail B. Overridden C. An interface D. Overloaded 17. Given: 1. public class Example 2. public static void main(String args) 3. new Example().locate(1.0, 2); 4. 5. private void locate(do

25、uble a, long b) 6. System.out.println(double-long); 7. 8. private void locate(long a, int b) 9. System.out.println(long-int); 10. 11. What will happen when you compile and run this program? b A. The code will compile, run and display double-long. B. The code will compile, run and display long-int. C

26、. The code will not compile. D. The code will compile, but throw a runtime exception when executed. 18. Given: 1. class SuperTest 2. public SuperTest() 3. System.out.println( Super! ); 4. 5. 6. 7. class Test extends SuperTest 8. public static void main(String args) 9. new Test(); 10. 11. public Test

27、() 12. super(); 13. this( Great! ); 14. 15. 16. public Test(String name) 17. System.out.println(name); 18. 19. What is the result of this code? f/*thissuper*/ A. Great! Super! B. Super! Great! C. Super! Super! Great! D. Great! E. Super! F. This code will not compile. 19. Given: 1. public class Test

28、2. public static void main(String args) 3. new Test(4); 4. 5. public Test() 6. System.out.println(okay); 7. 8. public Test(int i) 9. 10. 11. Which of the following lines of code should be inserted at line 11 so that the output of the program is okay? c A. super(); B. this; C. Test(); D. this(); E. super(); 20. Given: 1. public class

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

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