版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、Java Certification Mock ExamJohn HuntEmail: jjhaber.ac.ukURL: /www.aber.ac.uk/jjh/JavaAs with any examination technique is an important aspect of the examination process.In most situations there are mock examinations that you can use to obtain experience.This is the intention of this Java Certificat
2、ion Mock Exam.This mock exam is solely intended to help those intending to take Suns Certified JavaProgrammer 1.1. examination practice the style of questions used in the examination.It should not be used as a way of learning Java nor should it be treated as a form ofrevision.Note some care has been
3、 taken to ensure that the style of questions are the same asthose in the actual exam, but that no questions from the examination are actuallyincluded. The style is based on one persons experience of taking the Java Certificationexamination and it should therefore not be assumed that this mock exam i
4、s an exactreflection of the actual exam.This mock examination consists of 65 questions (the actual exam consists of 60questions).Just as in the actual examination a mixture of style of questions are included. Theserange between questions that require a single answer and those that require 1 or morea
5、nswers. The former are indicated by: Select the most appropriate answer.Java Certification Mock Exam 1/36The latter by: Select all correct answers.Note a question that has the above request may require only one option, it is for you todecide. However, if you do not identify all the options for that
6、question, then you willscore zero for that question. One free format question is included as an example of thatstyle of questioning.As in the actual exam you should not attempt to identify any trends relating to As, Bsor Cs. That is, do not assume that because the answer A has not appeared for a whi
7、lethere is a good chance that it will soon.For the actual examination the pass mark is 70% you should therefore aim to achieveat least 46 correct answers in this mock examination.The correct answers are give at the end of the examination.Disclaimer: This mock examination is in no way sanctioned by S
8、un Microsystemsand no guarantees are provided about the similarity of these questions to those in theactual exam.Q. 1Which colour is used to indicate instance methods in the standard javadoc formatdocumentation:A. blueB. redC. purpleD. orangeJava Certification Mock Exam 2/36Select the most appropria
9、te answer.Q. 2What is the correct ordering for the import, class and package declarations when foundin a single file?A. package, import, classB. class, import, packageC. import, package, classD. package, class, importSelect the most appropriate answer.Q. 3Which methods can be legally applied to a st
10、ring object?A. equals(String)B. equals(Object)C. trim()D. round()E. toString()Select all correct answers.Q. 4What is the parameter specification for the public static void main method?A. String args B. String argsC. Strings args D. String argsSelect all correct answers.Q. 5What does the zeroth eleme
11、nt of the string array passed to the public static void mainJava Certification Mock Exam 3/36method contain?A. The name of the programB. The number of argumentsC. The first argument if one is presentSelect the most appropriate answer.Q. 6Which of the following are Java keywords?A. gotoB. mallocC. ex
12、tendsD. FALSESelect 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);A. Compiles and runs with no outputB. Compiles and runs printing out The age is 1C. C
13、ompiles but generates a runtime errorJava Certification Mock Exam 4/36D. Does not compileE. Compiles but generates a compile time errorSelect the most appropriate answer.Q. 8Which of these is the correct format to use to create the literal char value a?A. aB. aC. new Character(a)D. 000aSelect the mo
14、st appropriate answer.Q. 9What is the legal range of a byte integral type?A. 0 - 65, 535B. (128) 127C. (32,768) 32,767D. (256) 255Select the most appropriate answer.Q. 10Which of the following is illegal:A. int i = 32;B. float f = 45.0;C. double d = 45.0;Select the most appropriate answer.Q. 11What
15、will be the result of compiling the following code:Java Certification Mock Exam 5/36public class Test static int age;public static void main (String args ) age = age + 1;System.out.println(The age is + age);A. Compiles and runs with no outputB. Compiles and runs printing out The age is 1C. Compiles
16、but generates a runtime errorD. Does not compileE. Compiles but generates a compile time errorSelect the most appropriate answer.Q. 12Which of the following are correct?A. 128 1 gives 64B. 128 1 gives 64C. 128 1 gives 64D. 128 1 gives 64Select all correct answersQ. 13Which of the following return tr
17、ue?A. john = johnB. john.equals(john)C. john = johnJava Certification Mock Exam 6/36D. john.equals(new Button(john)Select all correct answers.Q. 14Which of the following do not lead to a runtime error?A. john + was + hereB. john + 3C. 3 + 5D. 5 + 5.5Select all correct answers.Q. 15Which of the follo
18、wing are so called short circuit logical operators?A. &B. |C. &D. |Select all correct answers.Q. 16Which of the following are acceptable?A. Object o = new Button(A);B. Boolean flag = true;C. Panel p = new Frame();D. Frame f = new Panel();E. Panel p = new Applet();Select all correct answers.Q. 17Java
19、 Certification Mock Exam 7/36What 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.print
20、ln(temp);A. The class will not compileB. The compiler reports and error at line 2C. The compiler reports an error at line 9D. The value 10 is one of the elements printed to the standard outputE. The class compiles but generates a runtime errorSelect all correct answers.Q 18Java Certification Mock Ex
21、am 8/36Which of the following is correct:A. String temp = new String j a z;B. String temp = j b c;C. String temp = a, b, c;D. 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:A. public abstract void add(
22、);B. public abstract void add() C. public abstract add();D. public virtual add();Select the most appropriate answer.Q. 20Under what situations do you obtain a default constructor?A. When you define any classB. When the class has no other constructorsC. When you define at least one constructorSelect
23、the most appropriate answer.Q. 21Given the following code:public class Test Java Certification Mock Exam 9/36Which of the following can be used to define a constructor for this class:A. public void Test() B. public Test() C. public static Test() D. public static void Test() Select the most appropria
24、te answer.Q. 22Which of the following are acceptable to the Java compiler:A. if (2 = 3) System.out.println(Hi);B. if (2 = 3) System.out.println(Hi);C. if (true) System.out.println(Hi);D. if (2 != 3) System.out.println(Hi);E. if (aString.equals(hello) System.out.println(Hi);Select all correct answers
25、.Q. 23Assuming a method contains code which may raise an Exception (but not aRuntimeException), what is the correct way for a method to indicate that it expects thecaller to handle that exception:A. throw ExceptionB. throws ExceptionC. new ExceptionD. Dont need to specify anythingSelect the most app
26、ropriate answer.Q. 24What is the result of executing the following code, using the parameters 4 and 0:Java Certification Mock Exam 10/36public void divide(int a, int b) try int c = a / b; catch (Exception e) System.out.print(Exception ); finally System.out.println(Finally);A. Prints out: Exception F
27、inallyB. Prints out: FinallyC. Prints out: ExceptionD. No outputSelect the most appropriate answer.Q.25Which of the following is a legal return type of a method overloading the followingmethod:public void add(int a) A. voidB. intC. Can be anythingSelect the most appropriate answer.Q.26Java Certifica
28、tion Mock Exam 11/36Which of the following statements is correct for a method which is overriding thefollowing method:public void add(int a) A. the overriding method must return voidB. the overriding method must return intC. the overriding method can return whatever it likesSelect the most appropria
29、te answer.Q. 27Given 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 Java Certification Mock Exam 12/36public static void main (String a
30、rgs ) 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?A. Generates a Compiler error on the statement v= c;B. Generates runtime error on the statement v= c;C. Prints out:Vehicle: driveCar: driveCar: d
31、riveD. Prints out:Vehicle: driveCar: driveVehicle: driveSelect the most appropriate answer.Java Certification Mock Exam 13/36Q. 28Where in a constructor, can you place a call to a constructor defined in the super class?A. AnywhereB. The first statement in the constructorC. The last statement in the
32、constructorD. You cant call super in a constructorSelect the most appropriate answer.Q. 29Which variables can an inner class access from the class which encapsulates it?A. All static variablesB. All final variablesC. All instance variablesD. Only final instance variablesE. Only final static variable
33、sSelect all correct answers.Q. 30What class must an inner class extend:A. The top level classB. The Object classC. Any class or interfaceD. It must extend an interfaceSelect the most appropriate answer.Q. 31In the following code, which is the earliest statement, where the object originally heldin e,
34、 may be garbage collected:1. public class Test Java Certification Mock Exam 14/362. public static void main (String args ) 3. Employee e = new Employee(Bob, 48);4. e.calculatePay();5. System.out.println(e.printDetails();6. e = null;7. e = new Employee(Denise, 36);8. e.calculatePay();9. System.out.pr
35、intln(e.printDetails();10.11. A. Line 10B. Line 11C. Line 7D. Line 8E. NeverSelect the most appropriate answer.Q. 32What is the name of the interface that can be used to define a class that can executewithin its own thread?A. RunnableB. RunC. ThreadableD. ThreadE. ExecutableSelect the most appropria
36、te answer.Q. 33What is the name of the method used to schedule a thread for execution?A. init();B. start();C. run();D. resume();E. sleep();Java Certification Mock Exam 15/36Select the most appropriate answer.Q. 34Which methods may cause a thread to stop executing?A. sleep();B. stop();C. yield();D. w
37、ait();E. notify();F. notifyAll()G. synchronized()Select all correct answers.Q. 35Write code to create a text field able to display 10 characters (assuming a fixed sizefont) displaying the initial string hello:Q. 36Which of the following methods are defined on the Graphics class:A. drawLine(int, int,
38、 int, int)B. drawImage(Image, int, int, ImageObserver)C. drawString(String, int, int)D. add(Component);E. setVisible(boolean);F. setLayout(Object);Select all correct answers.Q. 37Which of the following layout managers honours the preferred size of a component:Java Certification Mock Exam 16/36A. Car
39、dLayoutB. FlowLayoutC. BorderLayoutD. GridLayoutSelect 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);A. Generate a runti
40、me errorB. Throw an ArrayIndexOutOfBoundsExceptionC. Print the values: 1, 2, 2, 4D. Produces no outputSelect the most appropriate answer.Java Certification Mock Exam 17/36Q. 39What is the effect of issuing a wait() method on an objectA. If a notify() method has already been sent to that object then
41、it has no effectB. The object issuing the call to wait() will halt until another object sends a notify()or notifyAll() methodC. An exception will be raisedD. The object issuing the call to wait() will be automatically synchronized with anyother objects using the receiving object.Select the most appr
42、opriate answer.Q. 40The layout of a container can be altered using which of the following methods:A. setLayout(aLayoutManager);B. addLayout(aLayoutManager);C. layout(aLayoutManager);D. setLayoutManager(aLayoutManager);Select all correct answers.Q. 41Using a FlowLayout manager, which is the correct w
43、ay to add elements to a container:A. add(component);B. add(Center, component);C. add(x, y, component);D. set(component);Select the most appropriate answer.Q. 42Given that a Button can generate an ActionEvent which listener would you expect tohave to implement, in a class which would handle this even
44、t?Java Certification Mock Exam 18/36A. FocusListenerB. ComponentListenerC. WindowListenerD. ActionListenerE. ItemListenerSelect the most appropriate answer.Q. 43Which of the following, are valid return types, for listener methods:A. booleanB. the type of event handledC. voidD. ComponentSelect the mo
45、st appropriate answer.Q. 44Assuming we have a class which implements the ActionListener interface, whichmethod should be used to register this with a Button?A. addListener(*);B. addActionListener(*);C. addButtonListener(*);D. setListener(*);Select the most appropriate answer.Q. 45In order to cause t
46、he paint(Graphics) method to execute, which of the following is themost appropriate method to call:A. paint()B. repaint()C. paint(Graphics)D. update(Graphics)E. None you should never cause paint(Graphics) to executeJava Certification Mock Exam 19/36Select the most appropriate answer.Q. 46Which of th
47、e following illustrates the correct way to pass a parameter into an applet:A. B. C. D. Select the most appropriate answer.Q. 47Which of the following correctly illustrate how an InputStreamReader can becreated:A. new InputStreamReader(new FileInputStream(data);B. new InputStreamReader(new FileReader
48、(data);C. new InputStreamReader(new BufferedReader(data);D. new InputStreamReader(data);E. 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?A. The data is
49、 appended to the fileB. The file is replaced with a new fileC. An exception is raised as the file already existsD. The data is written to random locations within the fileSelect the most appropriate answer.Q. 49Java Certification Mock Exam 20/36What is the effect of adding the sixth element to a vect
50、or created in the followingmanner:new Vector(5, 10);A. An IndexOutOfBounds exception is raised.B. The vector grows in size to a capacity of 10 elementsC. The vector grows in size to a capacity of 15 elementsD. Nothing, the vector will have grown when the fifth element was addedSelect the most approp
51、riate 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);A. Nothing is printed outB. The value 3 is printed outC. The values 3 and 4 are printed outD. The val
52、ues 1, 3 and 4 are printed outJava Certification Mock Exam 21/36Select 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
53、compiling and running the Second class?A. Nothing happensB. A string is printed to the standard outC. An instance of the class First is generatedD. An instance of the class Second is createdE. An exception is raised at runtime stating that there is no null parameterconstructor in class First.F. The
54、class second will not compile as there is no null parameter constructor in theclass FirstSelect the most appropriate answer.Q. 52 What is the result of executing the following fragment of code:Java Certification Mock Exam 22/36boolean flag = false;if (flag = true) System.out.println(true); else System.out.println(false);A. true is printed to standard outB. false is printed to standard outC. An exception is raisedD. Nothing happensSelect the most appropriate answer.Q. 53Consider the following classes:publ
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2026及未来5-10年无镍眼镜框丝项目投资价值市场数据分析报告
- 2026及未来5-10年手摇桶式泵项目投资价值市场数据分析报告
- 2026卢森堡金属冶炼行业市场现状发展策略投资评估分析研究报告
- 2026卢旺达农业科技行业市场供需探讨及发展策略规划分析研究报告
- 2026南非黄金矿产储备现状与可持续发展政策环境分析报告
- 2026南非智能的物流行业市场当前供需分析及发展前景规划分析研究报告
- 2026南非-黄金行业市场供需分析及投资评估规划分析研究报告
- 2026区块链技术在金融领域的应用及合规发展研究报告
- 2026动力锂电池回收网络建设与运营模式优化研究报告
- 校园雨具租赁2025年共享经济模式创新报告
- 国资委安全生产十条硬措施
- 2026年湖北省高三(4月)调研模拟考试地理试卷(含答案)
- 2026内蒙古呼伦贝尔市林草执法人员招聘35人考试模拟试题及答案解析
- 2026年北京中考数学二轮复习 难点06 新定义综合题几何与函数(4大题型)(重难专练)
- (二模)2026年广州市普通高中高三毕业班综合测试(二)物理试卷(含答案及解析)
- 2026年马工程民法学配套基础试题库及一套完整答案详解
- 2026执业医师定期考核真题库(含答案)
- 2026年天津食品集团有限公司校园招聘笔试备考试题及答案解析
- 【2026年中考复习】全国中考物理真卷综合能力题100道(上)
- 残联出纳会计责任制度
- 屋顶分布式光伏发电技术交底
评论
0/150
提交评论