Java试题及答案英文版

上传人:夏** 文档编号:505228213 上传时间:2022-11-12 格式:DOC 页数:28 大小:157KB
返回 下载 相关 举报
Java试题及答案英文版_第1页
第1页 / 共28页
Java试题及答案英文版_第2页
第2页 / 共28页
Java试题及答案英文版_第3页
第3页 / 共28页
Java试题及答案英文版_第4页
第4页 / 共28页
Java试题及答案英文版_第5页
第5页 / 共28页
点击查看更多>>
资源描述

《Java试题及答案英文版》由会员分享,可在线阅读,更多相关《Java试题及答案英文版(28页珍藏版)》请在金锄头文库上搜索。

1、1Which two demonstrate an “is a” relationship? (Choose Two) A. public interface Person public class Employee extends Person B. public interface Shape public class Employee extends Sha pe C. public interface Color public class Employee extends Color D. public class Species public class Animalprivate

2、Species species;E. interface Component Class Container implements Component ( Private Component children;Answer :de2. Given:1. package foo;2. 3. public class Outer (4. public static class Inner (5. )6. )Which statement is true? A. An instance of the Inner class can be constructed with “new Outer.Inn

3、er ()”B. An instance of the inner class cannot be constructed outside of package fooC. An instance of the inner class can only be constructed from within the outer classD. From within the package bar, an instance of the inner class can be constructed with “new inner()”Answer:c3Exhibit:1 public class

4、 enclosinggone2 public class insideone3 4 public class inertest5 public static void main (String args)6 enclosingone eo = new enclosingone();7 /insert code here8 Which statement at line 7 constructs an instance of the inner class?A. InsideOne ei = eo.new InsideOne(); B. B. Eo.InsideOne ei = eo.new I

5、nsideOne();C InsideOne ei = EnclosingOne.new InsideOne();D.EnclosingOne InsideOne ei = eo.new InsideOne();Answer:aC. 4. D. 1) class Super E. 2) public float getNum()return 3.0f; F. 3) G. 4) H. 5) public class Sub extends Super I. 6) J. 7) K. which method, placed at line 6, will cause a compiler erro

6、r? L. A. public float getNum()return 4.0f; M. B. public void getNum() N. C. public void getNum(double d) O. D. public double getNum(float d)return 4.0d; Answer :B5. 1)public class Foo 2)public static void main(String args) 3)tryreturn; 4)finally System.out.println(Finally); 5) 6) what is the result?

7、 A. The program runs and prints nothing.B. The program runs and prints “Finally”.C. The code compiles, but an exception is thrown at runtime.D. The code will not compile because the catch block is missing.Answer:b 6 /point X public class Foo public static void main(String args) PrintWriter out=new P

8、rintWriter(new java.io.OutputStreamWriter(System.out),true); out.println(Hello); which statement at point X on line 1 allows this code to compile and run? A.import java.io.PrintWriter B.include java.io.PrintWriter C.import java.io.OutputStreamWriter D.include java.io.OutputStreamWriter E.No statemen

9、t is needed Answer:a7. which three are valid declaraction of a float? A. float foo=-1; B. float foo=1.0; C. float foo=42e1; D. float foo=2.02f; E. float foo=3.03d; F. float foo=0x0123;Answer:adf8. int index=1; int foo=new int3; int bar=fooindex;int baz=bar+index;what is the result? A. baz has a valu

10、e of 0 B. baz has value of 1 C. baz has value of 2 D. an exception is thrown E. the code will not compile Answer:b91)int i=1,j=10; 2)do 3)if(i+-j) continue; 192837464)while(i5); After Execution, what are the value for i and j? A. i=6 j=5 B. i=5 j=5 C. i=6 j=4 D. i=5 j=6 E. i=6 j=6 Answer: d10 1)publ

11、ic class X 2) public Object m() 3) Object o=new Float(3.14F); 4) Object oa=new Object1; 5) oa0=o; 6) o=null; 7) oa0=null; 8)System.out.println(oa0); 9) 10) which line is the earliest point the object a refered is definitely elibile to be garbage collectioned? A.After line 4 B. After line 5 C.After l

12、ine 6 D.After line 7 E.After line 9Answer: d11 1. public class X 2. public static void main(String args) 3. Object o1= new Object(); 4. Object o2= o1; 5. if(o1 .equals(o2) 6. System.out.println(Equal); 7. 8. 9. What is the result? A. The program runs and prints nothing. B. The program runs and print

13、s Equal. C. An error at line 5 causes compilation to fail. D. The program runs but aborts with an exception. Answer :B12 1)public class Test 2) public static void add3(Integer i) 3) int val=i.intValue(); 4) val+=3; 5) i=new Integer(val); 6) 7) public static void main(String args) 8) Integer i=new In

14、teger(0); 9) add3(i); 10) System.out.println(i.intValue(); 11) 12) what is the result? A. compile fail B.print out 0 C.print out 3 D.compile succeded but exception at line 3 Answer: b13.Given:1. public class Foo 2. public void main (String args) 3. system.out.printIn(“Hello World.”);4. 5. What is the result?A.An exception is thrown.B.T

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 医学/心理学 > 基础医学

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号