已阅读5页,还剩24页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
SCJP模拟试题三-此套试题由60道题组成(实际考试为60道题)。试题由单选题和多选题组成,单选题将提示:Select the most appropriate answer,多选题将提示:Select all correct answers。答案在最后。-Q. 1Which colour is used to indicate instance methods in the standard javadoc format documentation:blue red purple orange Select the most appropriate answer.Q. 2What is the correct ordering for the import, class and package declarations when found in a single file?package, import, class class, import, package import, package, class package, class, import Select the most appropriate answer.Q. 3Which methods can be legally applied to a string object?equals(String) equals(Object) trim() round() toString() Select all correct answers.Q. 4What is the parameter specification for the public static void main method?String args String args Strings args String args Select all correct answers.Q. 5What does the zeroth element of the string array passed to the public static void main method contain?The name of the program The number of arguments The first argument if one is present Select the most appropriate answer.Q. 6Which of the following are Java keywords?goto malloc extends FALSE Select all correct answersQ. 7What will be the result of compiling the following code:public class Test public static void main (String args ) int age;age = age + 1;System.out.println(The age is + age);Compiles and runs with no output Compiles and runs printing out The age is 1 Compiles but generates a runtime error Does not compile Compiles but generates a compile time error Select the most appropriate answer.Q. 8Which of these is the correct format to use to create the literal char value a?a a new Character(a) 000a Select the most appropriate answer.Q. 9What is the legal range of a byte integral type?0 - 65, 535 (128) 127 (32,768) 32,767 (256) 255 Select the most appropriate answer.Q. 10Which of the following is illegal:int i = 32; float f = 45.0; double d = 45.0; Select the most appropriate answer.Q. 11What will be the result of compiling the following code:public class Test static int age;public static void main (String args ) age = age + 1;System.out.println(The age is + age);Compiles and runs with no output Compiles and runs printing out The age is 1 Compiles but generates a runtime error Does not compile Compiles but generates a compile time error Select the most appropriate answer.Q. 12Which of the following are correct?128 1 gives 64 128 1 gives 64 128 1 gives 64 128 1 gives 64 Select all correct answersQ. 13Which of the following return true?john = john john.equals(john) john = john john.equals(new Button(john) Select all correct answers.Q. 14Which of the following do not lead to a runtime error?john + was + here john + 3 3 + 5 5 + 5.5 Select all correct answers.Q. 15Which of the following are so called short circuit logical operators?& | & | Select all correct answers.Q. 16Which of the following are acceptable?Object o = new Button(A); Boolean flag = true; Panel p = new Frame(); Frame f = new Panel(); Panel p = new Applet(); Select all correct answers.Q. 17What is the result of compiling and running the following code:public class Test static int total = 10;public static void main (String args ) new Test();public Test () System.out.println(In test);System.out.println(this);int temp = this.total;if (temp 5) System.out.println(temp);The class will not compile The compiler reports and error at line 2 The compiler reports an error at line 9 The value 10 is one of the elements printed to the standard output The class compiles but generates a runtime error Select all correct answers.Q 18Which of the following is correct:String temp = new String j a z; String temp = j b c; String temp = a, b, c; String temp = a, b, c; Select the most appropriate answer.Q. 19What is the correct declaration of an abstract method that is intended to be public:public abstract void add(); public abstract void add() public abstract add(); public virtual add(); Select the most appropriate answer.Q. 20Under what situations do you obtain a default constructor?When you define any class When the class has no other constructors When you define at least one constructor Select the most appropriate answer.Q. 21Given the following code:public class Test Which of the following can be used to define a constructor for this class:public void Test() public Test() public static Test() public static void Test() Select the most appropriate answer.Q. 22Which of the following are acceptable to the Java compiler:if (2 = 3) System.out.println(Hi); if (2 = 3) System.out.println(Hi); if (true) System.out.println(Hi); if (2 != 3) System.out.println(Hi); if (aString.equals(hello) System.out.println(Hi); Select all correct answers.Q. 23Assuming a method contains code which may raise an Exception (but not a RuntimeException), what is the correct way for a method to indicate that it expects the caller to handle that exception:throw Exception throws Exception new Exception Dont need to specify anything Select the most appropriate answer.Q. 24What is the result of executing the following code, using the parameters 4 and 0:public void divide(int a, int b) try int c = a / b; catch (Exception e) System.out.print(Exception ); finally System.out.println(Finally);Prints out: Exception Finally Prints out: Finally Prints out: Exception No output Select the most appropriate answer.Q.25Which of the following is a legal return type of a method overloading the following method:public void add(int a) void int Can be anything Select the most appropriate answer.Q.26 Which of the following statements is correct for a method which is overriding the following method:public void add(int a) the overriding method must return void the overriding method must return int the overriding method can return whatever it likes Select the most appropriate answer.Q. 27 Given the following classes defined in separate files:class Vehicle public void drive() System.out.println(Vehicle: drive);class Car extends Vehicle public void drive() System.out.println(Car: drive);public class Test public static void main (String args ) Vehicle v;Car c;v = new Vehicle();c = new Car();v.drive();c.drive();v = c;v.drive();What will be the effect of compiling and running this class Test?Generates a Compiler error on the statement v= c; Generates runtime error on the statement v= c; Prints out: Vehicle: driveCar: driveCar: drive Prints out: Vehicle: driveCar: driveVehicle: driveSelect the most appropriate answer.Q. 28Where in a constructor, can you place a call to a constructor defined in the super class?Anywhere The first statement in the constructor The last statement in the constructor You cant call super in a constructor Select the most appropriate answer.Q. 29Which variables can an inner class access from the class which encapsulates it?All static variables All final variables All instance variables Only final instance variables Only final static variables Select all correct answers.Q. 30What class must an inner class extend:The top level class The Object class Any class or interface It must extend an interface Select the most appropriate answer.Q. 31In the following code, which is the earliest statement, where the object originally held in e, may be garbage collected:public class Test public static void main (String args ) Employee e = new Employee(Bob, 48); e.calculatePay(); System.out.println(e.printDetails(); e = null; e = new Employee(Denise, 36); e.calculatePay(); System.out.println(e.printDetails(); Line 10 Line 11 Line 7 Line 8 Never Select the most appropriate answer.Q. 32What is the name of the interface that can be used to define a class that can execute within its own thread?Runnable Run Threadable Thread Executable Select the most appropriate answer.Q. 33What is the name of the method used to schedule a thread for execution?init(); start(); run(); resume(); sleep(); Select the most appropriate answer.Q. 34Which methods may cause a thread to stop executing?sleep(); stop(); yield(); wait(); notify(); notifyAll() synchronized() Select all correct answers.Q. 35Write code to create a text field able to display 10 characters (assuming a fixed size font) displaying the initial string hello:Q. 36Which of the following methods are defined on the Graphics class:drawLine(int, int, int, int) drawImage(Image, int, int, ImageObserver) drawString(String, int, int) add(Component); setVisible(boolean); setLayout(Object); Select all correct answers.Q. 37Which of the following layout managers honours the preferred size of a component:CardLayout FlowLayout BorderLayout GridLayout Select all correct answers.Q. 38Given the following code what is the effect of a being 5:public class Test public void add(int a) loop: for (int i = 1; i 3; i+)for (int j = 1; j 3; j+) if (a = 5) break loop;System.out.println(i * j);Generate a runtime error Throw an ArrayIndexOutOfBoundsException Print the values: 1, 2, 2, 4 Produces no output Select the most appropriate answer.Q. 39What is the effect of issuing a wait() method on an objectIf a notify() method has already been sent to that object then it has no effect The object issuing the call to wait() will halt until another object sends a notify() or notifyAll() method An exception will be raised The object issuing the call to wait() will be automatically synchronized with any other objects using the receiving object. Select the most appropriate answer.Q. 40The layout of a container can be altered using which of the following methods:setLayout(aLayoutManager); addLayout(aLayoutManager); layout(aLayoutManager); setLayoutManager(aLayoutManager); Select all correct answers.Q. 41Using a FlowLayout manager, which is the correct way to add elements to a container:add(component); add(Center, component); add(x, y, component); set(component); Select the most appropriate answer.Q. 42Given that a Button can generate an ActionEvent which listener would you expect to have to implement, in a class which would handle this event?FocusListener ComponentListener WindowListener ActionListener ItemListener Select the most appropriate answer.Q. 43Which of the following, are valid return types, for listener methods:boolean the type of event handled void Component Select the most appropriate answer.Q. 44Assuming we have a class which implements the ActionListener interface, which method should be used to register this with a Button?addListener(*); addActionListener(*); addButtonListener(*); setListener(*); Select the most appropriate answer.Q. 45In order to cause the paint(Graphics) method to execute, which of the following is the most appropriate method to call:paint() repaint() paint(Graphics) update(Graphics) None you should never cause paint(Graphics) to execute Select the most appropriate answer.Q. 46Which of the following illustrates the correct way to pass a parameter into an applet: Select the most appropriate answer.Q. 47Which of the following correctly illustrate how an InputStreamReader can be created:new InputStreamReader(new FileInputStream(data); new InputStreamReader(new FileReader(data); new InputStreamReader(new BufferedReader(data); new InputStreamReader(data); new InputStreamReader(System.in); Select all correct answers.Q. 48What is the permanent effect on the file system of writing data to a new FileWriter(report), given the file report already exists?The data is appended to the file The file is replaced with a new file An exception is raised as the file already exists The data is written to random locations within the file Select the most appropriate answer.Q. 49What is the effect of adding the sixth element to a vector created in the following manner:new Vector(5, 10); An IndexOutOfBounds exception is raised. The vector grows in size to a capacity of 10 elements The vector grows in size to a capacity of 15 elements Nothing, the vector will have grown when the fifth element was added Select the most appropriate answer.Q. 50What is the result of executing the following code when the value of x is 2:switch (x) case 1:System.out.println(1);case 2:case 3:System.out.println(3);case 4:System.out.println(4);Nothing is printed out The value 3 is printed out The values 3 and 4 are printed out The values 1, 3 and 4 are printed out Select the most appropriate answer.Q. 51Consider the following example:class First public First (String s) System.out.println(s);public class Second extends First public static void main(String args ) new Second();What is the result of compiling and running the Second class?Nothing happens A string is printed to the standard out An instance of the class First is generated An instance of the class Second is created An exception is raised at runtime stating that there is no null parameter constructor in class First. The class second will not compile as there is no null parameter constructor in the class First Select the most appropriate answer.Q. 52 What is the result of executing the following fragment of code:boolean flag = false;if (flag = true) System.out.println(true); else System.out.println(false);true is printed to standard out false is printed to standard out An exception is raised Nothing happens Select the most appropriate answer.Q. 53Consider the following classes:public class Test public static void test() this.print();public static void print() System.out.println(Test);public static void main(String args ) test();What is the result of compiling and running this class?The string Test is printed to the standard out. A runtime exception is raised stating that an object has not been created. Nothing is printed to the standard output. An exception is raised stating that the method test cannot be found. An exception is raised stating that the variable this can only be used within an instance. The class fails to compile stating that the variable this is undefined. Select all correct answers.Q. 54Examine the following class definition:public class Test public static void test() print();public static void print() System.out.println(Test);public void print() System.out.println(Another Test);What is the result of compiling this class:A successful compilation. A warning stating that the class has no main method. An error stating that there is a duplicated method. An error stating that the method test() will call one or other of the print() methods. Select the most appropriate answer.Q. 55What is the result of compiling and executing the following Java class:public class ThreadTest extends Thread public void run() System.out.println(In run);suspend();resume();System.out.println(Leaving run);public static void main(String args ) (new ThreadTest().start();Compilation will fail in the method main. Compilation will fail in the method run. A warning will be generated for method run. The string In run will be printed to standard out. Both strings will be printed to standard out. Nothing will happen. Select the most appropriate answer.Q. 56Given the following sequence of Java statementsStringBuffer sb = new StringBuffer(abc); String s = new String(abc); sb.append(def); s.append(def); sb.insert(1, zzz); s.concat(sb); s.trim(); Which of the
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 小蚂蚁的启示议论文:微小生命的力量5篇
- 2026年网络安全师笔试题精
- 2026年精神病健康知识讲座计划书
- 2026年化工工程师笔试高频题
- 2026年护士资格证实践技能考试模拟题
- 2026年安全教育知识-安全知识
- 2026年线上教学问题解决措施及方法
- 2026年物流师初级资格证考试指南
- 2026年安全行车基础知识
- 2026年常见老年病知识课件
- 2026广西能汇投资集团有限公司校园招聘笔试参考题库及答案解析
- 河南省顶级名校2026届高三年级5月押题导向卷(一)历史试卷(含答案及解析)
- 开封市汽车产业投资有限公司、开封市文心科教投资发展有限公司招聘笔试题库2026
- 市政起重吊装施工方案(3篇)
- 2026年陕西交通职业技术学院教师招聘笔试备考试题及答案解析
- 木门质检员制度及流程规范
- 2025贵州康体旅投发展有限公司实习生招聘2人参考笔试题库附答案解析
- 园区配套协议书
- 县域经济发展课件
- 行业技术故障排除手册
- 成人肠内营养支持护理团队标准
评论
0/150
提交评论