资源预览内容
第1页 / 共28页
第2页 / 共28页
第3页 / 共28页
第4页 / 共28页
第5页 / 共28页
第6页 / 共28页
第7页 / 共28页
第8页 / 共28页
第9页 / 共28页
第10页 / 共28页
亲,该文档总共28页,到这儿已超出免费预览范围,如果喜欢就下载吧!
资源描述
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 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.Inner ()”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 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 InsideOne();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 error? 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? 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 PrintWriter(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 statement 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 value 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)public 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 line 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 prints 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 Integer(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
收藏 下载该资源
网站客服QQ:2055934822
金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号