scjp mock exam 1

上传人:xins****2008 文档编号:115774672 上传时间:2019-11-14 格式:DOC 页数:6 大小:47.50KB
返回 下载 相关 举报
scjp mock exam 1_第1页
第1页 / 共6页
scjp mock exam 1_第2页
第2页 / 共6页
scjp mock exam 1_第3页
第3页 / 共6页
scjp mock exam 1_第4页
第4页 / 共6页
scjp mock exam 1_第5页
第5页 / 共6页
点击查看更多>>
资源描述

《scjp mock exam 1》由会员分享,可在线阅读,更多相关《scjp mock exam 1(6页珍藏版)》请在金锄头文库上搜索。

1、SCJP Mock Exam 1Q1 A method is . 1) an implementation of an abstraction. 2) an attribute defining the property of a particular abstraction. 3) a category of objects. 4) an operation defining the behavior for a particular abstraction. 5) a blueprint for making operations. Q2 An object is . 1) what cl

2、asses are instantiated from. 2) an instance of a class. 3) a blueprint for creating concrete realization of abstractions. 4) a reference to an attribute. 5) a variable. Q3 Which line contains a constructor in this class definition? public class Counter / (1) int current, step; public Counter(int sta

3、rtValue, int stepValue) / (2) set(startValue); setStepValue(stepValue); public int get() return current; / (3) public void set(int value) current = value; / (4) public void setStepValue(int stepValue) step = stepValue; / (5) 1) Code marked with (1) is a constructor 2) Code marked with (2) is a const

4、ructor 3) Code marked with (3) is a constructor 4) Code marked with (4) is a constructor 5) Code marked with (5) is a Constructor Q4 Given that Thing is a class, how many objects and reference variables are created by the following code? Thing item, stuff; item = new Thing(); Thing entity = new Thin

5、g(); 1) One object is created 2) Two objects are created 3) Three objects are created 4) One reference variable is created 5) Two reference variables are created 6) Three reference variables are created. Q5 An instance member 1) is also called a static member 2) is always a variable 3) is never a me

6、thod 4) belongs to a single instance, not to the class as a whole 5) always represents an operation Q6 How do objects pass messages in Java? 1) They pass messages by modifying each others member variables 2) They pass messages by modifying the static member variables of each others classes 3) They p

7、ass messages by calling each others instance member methods 4) They pass messages by calling static member methods of each others classes. Q7 Given the following code, which statements are true? class A int value1; class B extends A int value2; 1) Class A extends class B. 2) Class B is the superclas

8、s of class A. 3) Class A inherits from class B. 4) Class B is a subclass of class A. 5) Objects of class A have a member variable named value2. Q8 If this source code is contained in a file called SmallProg.java, what command should be used to compile it using the JDK? public class SmallProg public

9、static void main(String args) System.out.println(Good luck!); 1) java SmallProg 2) avac SmallProg 3) java SmallProg.java 4) javac SmallProg.java 5) java SmallProg main Q9 Given the following class, which statements can be inserted at position 1 without causing the code to fail compilation? public cl

10、ass Q6db8 int a; int b = 0; static int c; public void m() int d; int e = 0; / Position 1 1) a+; 2) b+; 3) c+; 4) d+; 5) e+; Q10 Which statements are true concerning the effect of the and operators? 1) For non-negative values of the left operand, the and operators will have the same effect. 2) The re

11、sult of (-1 1) is 0. 3) The result of (-1 1) is -1. 4) The value returned by will never be negative as long as the value of the right operand is equal to or greater than 1. 5) When using the operator, the leftmost bit of the bit representation of the resulting value will always be the same bit value

12、 as the leftmost bit of the bit representation of the left operand. Q11 What is wrong with the following code? class MyException extends Exception public class Qb4ab public void foo() try bar(); finally baz(); catch (MyException e) public void bar() throws MyException throw new MyException(); public

13、 void baz() throws RuntimeException throw new RuntimeException(); 1) Since the method foo() does not catch the exception generated by the method baz(), it must declare the RuntimeException in its throws clause. 2) A try block cannot be followed by both a catch and a finally block. 3) An empty catch

14、block is not allowed. 4) A catch block cannot follow a finally block. 5) A finally block must always follow one or more catch blocks. Q12 What will be written to the standard output when the following program is run? public class Qd803 public static void main(String args) String word = restructure;

15、System.out.println(word.substring(2, 3); 1) est 2) es 3) str 4) st 5) s Q13 Given that a static method doIt() in a class Work represents work to be done, what block of code will succeed in starting a new thread that will do the work? CODE BLOCK A: Runnable r = new Runnable() public void run() Work.d

16、oIt(); ; Thread t = new Thread(r); t.start(); CODE BLOCK B: Thread t = new Thread() public void start() Work.doIt(); ; t.start(); CODE BLOCK C: Runnable r = new Runnable() public void run() Work.doIt(); ; r.start(); CODE BLOCK D: Thread t = new Thread(new Work(); t.start(); CODE BLOCK E: Runnable t = new Runnable() public void run()

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 大杂烩/其它

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号