最新10月test.doc_第1页
最新10月test.doc_第2页
最新10月test.doc_第3页
最新10月test.doc_第4页
最新10月test.doc_第5页
已阅读5页,还剩7页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1. Given:public class ReturnItReturnType methodA(byte x,double y)return (short)x/y*2;What is the valid return for methodA in line2?A. int B. byte C. long D. short E. float F. doubleF2. Given:abstract class AbstractItabstract float getFloat();public class AbstractTest extends AbstractItprivate float f1 = 1.0f;private float getFloat()retrun f1;What is the result?A. Compilation is successfulB. An error on line 6 causes a runtime failureC. An error at line 6 causes compilation to failD. An error at line 2 causes compilation to failC3. Which declaration prevents creating a subclass of an outer class?A. static class FooBarB. private class FooBarC. abstract class FooBarD. final public class FooBarE. final abstract class FooBarD4. Given:byte array1,array2;byte array3;byte array4;if each array has been initialized, which statement will cause a compiler error?A. array2 = array1B. array2=array3C. array2=array4D. both A and BE. both A and CF. both B and CA5.public class Testpublic int aMethod()static int i=0;i+;return i;public static void main(String args)Test test = new Test();test.aMethod();int j=test.aMethod();System.out.println(j);What is the result?A. Compilation will failB. Compilation will succeed and the program will print”0”.C. Compilation will succeed and the program will print”1”.D. Compilation will succeed and the program will print”2”.A6.You want subclasses in any package to have access to members of a superclass. Which is the most restrictive access modifier that will accomplisher this objective?A. public B. private C. protectedD. transientE. No access modifier is qualifiedC7.class Superpublic int i=0;public Super(String text)i=1;public class Sub extends Superpublic Sub(String text)i=2;public static void main(String ag)Sub sub=new Sub(“Hello”);System.out.println(sub.i);What is the result?A. Compilation will failB. Compilation will succeed and the program will print”0”.C. Compilation will succeed and the program will print”1”D. Compilation will succeed and the program will print”2”A8. Given:class Superpublic float getNum()return 3.0f;public class Sub extends SuperWhich method , placed at line 6,will cause a complier error?A. public float getNum()return 4.0f;B. public void getNum()C. public void getNum(double d)D. public double getNum(float d)return 4.0d;B9. public class Testpublic static void main(String args)int i=0;while(1)if(i=4)break;i+;What is the value of i at line 10?A. 0 B. 3 C. 4 D. 5 E. The code will not compileE10.Given:int i=1,j=10;doif(i+-j) continue;while(i5);After execution, what are the values for i and j?A. i=6 and j=5B. i=5 and j=5C. i=6 and j=4D. i=5 and j=6E. i=6 and j=6D11.Given:public class IfElsepublic static void main(String args)if(odd(5)System.out.println(“odd”);elseSystem.out.println(“Even”);public static int odd(int x)return x%2;What is the result?A. The output is odd;B. The output is even;C. An error on line 3 causes compilation to failD. An error on line 8 causes compilation to failC12import java.io.IOException;public class ExceptionTestpublic static void main(String args)trymethodA();catch(IOException e)System.out.println(“Caught IOException”);catch(Exception e)System.out.println(“Caught Exception”);public static void methodA()throw new IOException();What is the result?A. The code will not compile;B. The output is Caught ExceptionC. The output is Caught IOExceptionD. The program executes normally without printing a messageA13public class Testpublic static String output = “”;public static void foo(int i)tryif(i=1)throw new Exception();output += “1”;catch(Exception e)output += “2”;return;finallyoutput += “3”;output += “4”;public static void main(String args)foo(0);foo(1);What is the value of the variable output at line 24?Shortanswer:1342314.Given:public class Foopublic static void main(String args)tryreturn;finallySystem.out.println(“Finally”);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.B15.Given public class IfTestpublic static void main(String s)int x=3;int y=1;if(x=y)System.out.println(“Not equal”);elseSystem.out.println(“Equal”);What is the result?A. The output is “Equal”.B. The output is “Not equal”C. An error at line 5 causes compilation to failD. The program executes but does not print a messageC16.Givenpublic class Xpublic Object m()Object o = new Float(3.14F);Object oa = new Object1;oa0 = o;o=null;return oa0;When is the Float object, created in line 3,eligible for garbage collection?A. just after line 5B. just after line 6C. just after line 7(that is,as the method returns)D. never in this methodD17.Which two are reserved words in Java?(2)A. runB. import C. defaultD. implementB、C18.Givenpublic class Test public static void main(String sg)String foo=sg1;String bar=sg2;String baz=sg3;And command line invocation:Java Test red green blueWhat is the result?A. baz has the value of “”B. baz has the value of nullC. baz has the value of “red”D. baz has the value of “blue”E. baz has the value of “green”F. The code will not compileB19.Given:int index = 1;boolean test = new boolean3;boolean foo=testindex;What is the result?A. foo has the value of o.B. foo has the value of null.C. foo has the value of true.D. foo has the value of falseE. An exception is thrownF. The code will not compileD20/Point Xpublic class Foopublic static void main(String args) throws ExceptionPrintWriter out = new PrintWriter(newjava.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 neededA22.Which three are valid declarations of a float?(3)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;.A、D、F23.interface Fooint k=0;public class Test implements Foopublic static void main(String args)int i;Test test = new Test();i=test.k;i=Test.k;i=Foo.k;A. Compilation succeeds.B. An error at line 2 causes compilation to fail.C. An error at line 9 causes compilation to fail.D. An error at line 10 causes compilation to fail.E. An error at line 11 causes compilation to fail.A24.public class Foopublic static void main(String sgf)StringBuffer a = new StringBuffer(A);StringBuffer b = new StringBuffer(B);operate(a,b);System.out.println(a+,+b);static void operate(StringBuffer x,StringBuffer y)x.append(y);y=x;What is the result?A. The code compiles and prints “A.B”.B. The code compiles and prints “A.A”.C. The code compiles and prints “B.B”.D. The code compiles and prints “AB.B”.E. The code compiles and prints “AB.AB”.D25.Givenpublic class Testpublic static void main(String sss)int i=0xFFFFFFF1;int j=i;What is the value decimal value of j at line 5?A.0 B.1 C.14 D.-15 F. An error at line 3 causes compilation to failG. An error at line 4 causes compilation to failC26. Which two demonstrate an “is a” relationship?(2)A. public interface Personpublic class Employee extends PersonB. public interface Shapepublic interface Retangle extends ShapeC. public interface Colorpublic class Shapeprivate Color color;D. public class Speciespublic class Animalprivate Species species;E. interface Componentclass Container implements Componentprivate Component children;B、E27.GivenPackage foo;public class Outerpublic static class InnerWhich 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 foo;C. An instance of the Inner class can only be constructed from within the Outer class.D. From within the package bar, an instance of the Inner class can be constructed with “new Inner()”.A28.Which statement is true?A. An anonymous inner class may be declared as final.B. An anonymous inner class can be declared as private.C. An anonymous inner class can implement multiple interfaces .D. An anonymous inner class can access final variables in any enclosing scope.E. Construction of an instance of a static inner class requires an instance of the enclosing outer class.D29.Which statement is true?A. If only one thread is blocked in the wait method of an object, and another thread executes the notify method on that same object , then the first thread immediately resumes execution.B. If a thread is blocked in the wait method of an object, and another thread executes the notify method on the same object, it is still possible that the first thread might never resume execution.C. If a thread is blocked in the wait method of an object, and another thread executes the notify method on the same object, then the first thread definitely resumes execution as a direct and sole consequence of the notify call.D. If two threads are blocked in the wait method of one object , and another thread executes the notify method on the same object, then the thread that executed the wait call first definitely resumes execution as a direct and sole consequence of the notify call.B30 You are assigned the task of building a Panel containing a TextArea at the top, a Label directly below it, and a Button directly Below the Label. If the three components are added directly to the Panel, which layout manager can the Panel use to ensure that the TextArea absorbs all of the free vertical space when the Panel is resized?A. GridLayoutB. FlowLayoutC. GridBagLayoutD. CardLayoutE. BorderLayoutC31 Given:String foo =”ABCDE”foo.substring(3);foo.concat(“XYZ”);What is the value of the variable foo at line 4?Shortanswer:ABCDE32. Which statement about static inner classes is true?A. An anonymous class can be declared as static B. A static inner class cannot be a static member of the outer class C. A static inner class does not require an instance of the enclosing classD. Instance members of a static inner class can be referenced using the class name of the static inner classC33. Which statement is true for the class java.util.ArrayList?A. The elements in the collection are ordered.B. The collection is guaranteed to be immutableC. The elements in the clollection are guaranteed to be uniqueD. The elements in the clollection are accessed using a unique keyE. The elements in the clollection are guaranteed to be synchronizedA34. Which two cannot directly cause a thread to stop executing?A. exiting from a sy

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

最新文档

评论

0/150

提交评论