免费预览已结束,剩余1页可下载查看
下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
Q1 Given 1 public abstract class Prod 2 public abstract void prmth1 3 public static void prmth2 4 int mth2 30 5 System out println prmth2 mth2 6 7 public abstract void prmth3 8 What is the result A Compilation succeeds B Compilation fails because of an error on line 1 C Compilation fails because of an error on line 3 D Compilation fails because of an error on line 7 Q2 Given 1 public class ClassA 2 public static void main String args 3 4 switch x 5 default 6 System out println Here it is 7 8 9 The ClassA class can be compiled successfully by inserting one of three possible options on line 3 When inserted separately which three will allow compilation to succeed Choose three A int x 6 B short x 3 C char x y D long x 354 E boolean x true Q3 Given 1 public class NewGarb 2 public static Object getIt 3 Object rg new Integer 3 4 Object dg new Object 1 2 5 dg 0 1 rg 6 dg 0 0 rg 7 rg null 8 return rg 9 10 Which statement is true A The NewGarb class will not compile B The getIt method must not be declared as static C The NewGarb class compiles but receives an exception because dg is not set to null D The rg object is eligible for garbage collection after a call to the getIt method has returned Q4 Given 1 public class SetFor 2 3 public static void main String args 4 5 System out println You will need to use c 6 7 Which two additions will individually allow compilation to succeed Choose two A char c placed on line 2 B char c placed on line 4 C char c f placed on line 2 D char c f placed on line 4 E static char c placed on line 2 F char c new char placed on line 4 Q5 1 public class TeSet 2 public static void main String args 3 int m 2 4 int p 1 5 int t 0 6 for p m 8 m p t 9 10 11 System out println t equals t 12 13 What is the resulting value of t A 2 B 4 C 6 D 7 Q6 1 class IntType 2 public String getType String a int b char c 3 String holdit1 new String 4 holdit1 a 5 return holdit1 6 7 8 9 class OverType extends IntType 10 11 String holdit2 new String 12 holdit2 holdit2 concat This is concat a 13 return holdit2 14 15 16 public static void main String args 17 OverType ot new OverType 18 String x new String x 19 int y 1 20 char z b 21 System out println getType x y z 22 23 When inserted on line 10 which line will override the getType method allowing compilation to succeed and the output This is x A public Text getType String a int b char c B public Text getType int b String a char c C public String getType String a int b char c D public String getType int b String a char c Q7 1 public class MyThread implements Runnable 2 private String holdA This is 3 private int holdB 1 2 3 4 5 6 7 8 9 10 4 5 public static void main String args 6 MyThread z new MyThread 7 new Thread z start 8 new Thread z start 9 10 11 public synchronized void run 12 for int w 0 w 10 w 13 System out println holdA holdB w 14 15 16 What is the result A Compilation fails because of an error on line 6 B Compilation fails because of an error on line 11 C Compilation fails because of errors on lines 7 and 8 D Compilation succeeds and the program prints each value in the holdB array at the end of the This is line Each value is printed two times before the program ends and the values are not printed in sequential order E Compilation succeeds and the program prints each value in the holdB array at the end of the This is line Each value is printed in order from 1 to 10 and after the value 10 prints it starts printing the values 1 to 10 in order again Q8 1 import java awt 2 3 public class Birthdays extends Frame 4 Birthdays 5 super Birthday Reminder 6 String lblsP1 Name Birthday Address 7 String butnsP2 Add Save Exit 8 Panel panelTop new Panel 9 Panel panelBot new Panel 10 panelTop setLayout new GridLayout 3 2 3 3 11 for int x 0 x lblsP1 length x 12 panelTop add new Label lblsP1 x 13 panelTop add new TextField 14 15 for int y 0 y butnsP2 length y 16 panelBot add new Button butnsP2 y 17 18 add panelTop BorderLayout NORTH 19 add panelBot BorderLayout SOUTH 20 21 Which main method should you add to the Birthdays class to allow the program to compile and run with all defined fields properly displayed A public static void main String args Frame visible true B public static void main String args Frame f new Frame f setVisible true C public static void main String args Birthdays b new Birthdays b pack b setVisible true D public static void main String args Frame f Birthdays new Frame f pack f visible true Q9 1 public class GetIt 2 public static void main String args 3 double x 10 2 9 1 8 7 4 int i new int 3 5 for int a 0 a x length a 6 7 System out println i a 8 9 10 The GetIt class should print the following 11 10 9 Which line should you insert on line 6 to accomplish this A i a int Math min x a B i a int Math max x a C i a int Math ceil x a D i a int Math floor x a Q10 Which statement about the Map interface is true A Entries are placed in a Map using the values method B Entries are placed in a Map using the entrySet method C A key value association is added to a Map using the put method D A key value association is added to a Map using the putAll method Answers Q1 Option A is correct because a class must be declared abstract when it contains one or more abstract methods Abstract methods are methods without a body Options B C and D are incorrect because compilation succeeds Q2 Options A B and C are correct because a switch statement test requires an integer expression If the values in the expression are of type byte short or char promotion to the integer value will occur Options D and E are incorrect because class references floating point values and long values are not allowed in the expression Q3 Option D is correct because no accessible references to the object created at line 3 exist after the method returns This is because automatic variables are used for all the references in this code Option A is incorrect because the NewGarb class compiles successfully Option B is incorrect because the getIt method may or may not be declared static Option C is incorrect because an exception is not received Q4 Option D is correct because char c f placed on line 4 will create a local variable which is a variable declared within a method These variables exist only as long as the method exists Option E is correct because static char c placed on line 2 will create a class v ariable which is a variable declared within the class These variables are created and destroyed as the class is created and destroyed Option A is incorrect because it does not use the static keyword A variable that is accessed by a static method must be declared static or the access must be made using an instance reference Likewise option C is not declared static using the static keyword Option B is incorrect because it does not initialize the variable Option F is incorrect because char is not a class and so cannot be instantiated Q5 Option B is correct because t will result in a value of 4 The operator will increment variables by one Stepping through the for loop until p 5 incrementing the variables and performing the calculation will result in t being equal to 4 Q6 Option C is correct because the method name argument list and return type are the same as the getType method defined in the IntType class Overriding methods must be declared with the same name argument list and return type as the overridden method Option A is incorrect because the return type is not the same as the getType method in the IntType class Option B is incorrect because both the return type and argument list are different from the getType method in the IntType class Option D is incorrect because the argument list is different from the getType method in the IntType class Q7 Option E is correct because the Runnable interface is implemented by declaring a synchronized run method The method is declared as synchronized to signify that the object lock must be obtained Options A B and C are incorrect because compilation succeeds Option D is incorrect but would be correct if the run method were not declared as synchronized Q8 Option C is correct because it creates the Birthdays class and dis
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2026年水果模拟题目及答案详解
- 2026年机修钳工(中级)实操模拟考试题库及答案详解
- 2026年大专哲学模拟试卷(含答案)
- 2026年大学团校模拟试卷(含答案)
- 2026年骨产道异常预防模拟试题(含答案)
- 2026年鼻饲护理操作模拟试题(含答案)
- 2026年注册会计师CPA税法增值税计算专项练习题及答案详解
- 2026年给药原则模拟试题(含答案)
- 2026年规培医生结业模拟试题(含答案)
- 2026年公司轻烃装置操作工三级安全教育(车间级)考核模拟试卷及答案详解
- 2026年山东数学专升本历年真题及答案
- 理想L7 2026款改款车主手册说明书
- 2026年高考全国1卷语文高考试题(原卷版)
- WS+271-2026+感染性腹泻诊断标准
- 2026年水生生物病害防治员专项题库(附答案与解释)
- 2026-2030中国自动化细胞成像系统行业市场发展趋势与前景展望战略研究报告
- 2026年演出经纪人思想政治与法律基础真题回忆版
- 余热发电施工方案(3篇)
- GB 9745-2025航空轮胎
- mdsap培训教学课件
- 英雄屹立喀喇昆仑课件
评论
0/150
提交评论