⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 green模拟题4.htm

📁 非常好的java习题集
💻 HTM
📖 第 1 页 / 共 3 页
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0055)http://cuiguanyu.top263.net/pages/program/scjpexam4.htm -->
<HTML><HEAD><TITLE>SCJP模拟题4</TITLE>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<META content="MSHTML 5.50.4134.600" name=GENERATOR></HEAD>
<BODY bgColor=#d7edff>
<H1 align=center>SCJP Mock Exam 4</H1>
<P align=center>崔冠宇转载 Marcus Green</P>Q1 <BR>A method is ... <BR><BR>1) an 
implementation of an abstraction. <BR>2) an attribute defining the property of a 
particular abstraction. <BR>3) a category of objects. <BR>4) an operation 
defining the behavior for a particular abstraction. <BR>5) a blueprint for 
making operations. <BR><BR>Q2 <BR>An object is ... <BR><BR>1) what classes are 
instantiated from. <BR>2) an instance of a class. <BR>3) a blueprint for 
creating concrete realization of abstractions. <BR>4) a reference to an 
attribute. <BR>5) a variable. <BR><BR>Q3 <BR>Which line contains a constructor 
in this class definition? <BR><BR>public class Counter { // (1) <BR>int current, 
step; <BR>public Counter(int startValue, int stepValue) { // (2) 
<BR>set(startValue); <BR>setStepValue(stepValue); <BR>} <BR>public int get() { 
return current; } // (3) <BR>public void set(int value) { current = value; } // 
(4) <BR>public void setStepValue(int stepValue) { step = stepValue; } // (5) 
<BR>} <BR><BR>1) Code marked with (1) is a constructor <BR>2) Code marked with 
(2) is a constructor <BR>3) Code marked with (3) is a constructor <BR>4) Code 
marked with (4) is a constructor <BR>5) Code marked with (5) is a Constructor 
<BR><BR>Q4 <BR>Given that Thing is a class, how many objects and reference 
variables are created by the following code? <BR><BR>Thing item, stuff; <BR>item 
= new Thing(); <BR>Thing entity = new Thing(); <BR><BR>1) One object is created 
<BR>2) Two objects are created <BR>3) Three objects are created <BR>4) One 
reference variable is created <BR>5) Two reference variables are created <BR>6) 
Three reference variables are created. <BR><BR>Q5 <BR>An instance member… 
<BR><BR>1) is also called a static member <BR>2) is always a variable <BR>3) is 
never a method <BR>4) belongs to a single instance, not to the class as a whole 
<BR>5) always represents an operation <BR><BR>Q6 <BR>How do objects pass 
messages in Java? <BR><BR>1) They pass messages by modifying each other's member 
variables <BR>2) They pass messages by modifying the static member variables of 
each other's classes <BR>3) They pass messages by calling each other's instance 
member methods <BR>4) They pass messages by calling static member methods of 
each other's classes. <BR><BR>Q7 <BR>Given the following code, which statements 
are true? <BR><BR>class A { <BR>int value1; <BR>} <BR>class B extends A { 
<BR>int value2; <BR>} <BR><BR>1) Class A extends class B. <BR>2) Class B is the 
superclass of class A. <BR>3) Class A inherits from class B. <BR>4) Class B is a 
subclass of class A. <BR>5) Objects of class A have a member variable named 
value2. <BR><BR>Q8 <BR>If this source code is contained in a file called 
SmallProg.java, what command should be used to compile it using the JDK? 
<BR><BR>public class SmallProg { <BR>public static void main(String args[]) { 
System.out.println("Good luck!"); } <BR>} <BR><BR>1) java SmallProg <BR>2) avac 
SmallProg <BR>3) java SmallProg.java <BR>4) javac SmallProg.java <BR>5) java 
SmallProg main <BR><BR>Q9 <BR>Given the following class, which statements can be 
inserted at position 1 without causing the code to fail compilation? 
<BR><BR>public class Q6db8 { <BR>int a; <BR>int b = 0; <BR>static int c; 
<BR>public void m() { <BR>int d; <BR>int e = 0; <BR>// Position 1 <BR>} <BR>} 
<BR><BR>1) a++; <BR>2) b++; <BR>3) c++; <BR>4) d++; <BR>5) e++; <BR><BR>Q10 
<BR>Which statements are true concerning the effect of the &gt;&gt; and 
&gt;&gt;&gt; operators? <BR><BR>1) For non-negative values of the left operand, 
the &gt;&gt; and &gt;&gt;&gt; operators will have the same effect. <BR>2) The 
result of (-1 &gt;&gt; 1) is 0. <BR>3) The result of (-1 &gt;&gt;&gt; 1) is -1. 
<BR>4) The value returned by &gt;&gt;&gt; will never be negative as long as the 
value of the right operand is equal to or greater than 1. <BR>5) When using the 
&gt;&gt; operator, the leftmost bit of the bit representation of the resulting 
value will always be the same bit value as the leftmost bit of the bit 
representation of the left operand. <BR><BR>Q11 <BR>What is wrong with the 
following code? <BR><BR>class MyException extends Exception {} <BR><BR>public 
class Qb4ab { <BR>public void foo() { <BR>try { <BR>bar(); <BR>} finally { 
<BR>baz(); <BR>} catch (MyException e) {} <BR>} <BR>public void bar() throws 
MyException { <BR>throw new MyException(); <BR>} <BR>public void baz() throws 
RuntimeException { <BR>throw new RuntimeException(); <BR>} <BR>} <BR><BR>1) 
Since the method foo() does not catch the exception generated by the method 
baz(), it must declare the RuntimeException in its throws clause. <BR>2) A try 
block cannot be followed by both a catch and a finally block. <BR>3) An empty 
catch block is not allowed. <BR>4) A catch block cannot follow a finally block. 
<BR>5) A finally block must always follow one or more catch blocks. <BR><BR>Q12 
<BR>What will be written to the standard output when the following program is 
run? <BR><BR>public class Qd803 { <BR>public static void main(String args[]) { 
<BR>String word = "restructure"; <BR>System.out.println(word.substring(2, 3)); 
<BR>} <BR>} <BR><BR>1) est <BR>2) es <BR>3) str <BR>4) st <BR>5) s <BR><BR>Q13 
<BR>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? <BR><BR>CODE BLOCK A: <BR>Runnable r = new Runnable() { <BR>public void 
run() { <BR>Work.doIt(); <BR>} <BR>}; <BR>Thread t = new Thread(r); 
<BR>t.start(); <BR><BR>CODE BLOCK B: <BR>Thread t = new Thread() { <BR>public 
void start() { <BR>Work.doIt(); <BR>} <BR>}; <BR>t.start(); <BR><BR>CODE BLOCK 
C: <BR>Runnable r = new Runnable() { <BR>public void run() { <BR>Work.doIt(); 
<BR>} <BR>}; <BR>r.start(); <BR><BR>CODE BLOCK D: <BR>Thread t = new Thread(new 
Work()); <BR>t.start(); <BR><BR>CODE BLOCK E: <BR>Runnable t = new Runnable() { 
<BR>public void run() { <BR>Work.doIt(); <BR>} <BR>}; <BR>t.run(); <BR><BR>1) 
Code block A. <BR>2) Code block B. <BR>3) Code block C. <BR>4) Code block D. 
<BR>5) Code block E. <BR><BR>Q14 <BR>Write a line of code that declares a 
variable named layout of type LayoutManager and initializes it with a new 
object, which when used with a container can lay out components in a rectangular 
grid of equal-sized rectangles, 3 components wide and 2 components high. 
<BR><BR>Q15 <BR>public class Q275d { <BR>static int a; <BR>int b; <BR>public 
Q275d() { <BR>int c; <BR>c = a; <BR>a++; <BR>b += c; <BR>} <BR>public static 
void main(String args[]) { <BR>new Q275d(); <BR>} <BR>} <BR><BR>1) The code will 
fail to compile, since the constructor is trying to access static members. 
<BR>2) The code will fail to compile, since the constructor is trying to use 
static member variable a before it has been initialized. <BR>3) The code will 
fail to compile, since the constructor is trying to use member variable b before 
it has been initialized. <BR>4) The code will fail to compile, since the 
constructor is trying to use local variable c before it has been initialized. 
<BR>5) The code will compile and run without any problems. <BR><BR>Q16 <BR>What 
will be written to the standard output when the following program is run? 
<BR><BR>public class Q63e3 { <BR>public static void main(String args[]) { 
<BR>System.out.println(9 ^ 2); <BR>} <BR>} <BR><BR>1) 81 <BR>2) 7 <BR>3) 11 
<BR>4) 0 <BR>5) false <BR><BR>Q17 <BR>Which statements are true concerning the 
default layout manager for containers in the java.awt package? <BR><BR>1) 
Objects instantiated from Panel do not have a default layout manager. <BR>2) 
Objects instantiated from Panel have FlowLayout as default layout manager. 
<BR>3) Objects instantiated from Applet have BorderLayout as default layout 
manager. <BR>4) Objects instantiated from Dialog have BorderLayout as default 
layout manager. <BR>5) Objects instantiated from Window have the same default 
layout manager as instances of Applet. <BR><BR>Q18 <BR>Which declarations will 
allow a class to be started as a standalone program? <BR><BR>1) public void 
main(String args[]) <BR>2) public void static main(String args[]) <BR>3) public 
static main(String[] argv) <BR>4) final public static void main(String [] array) 
<BR>5) public static void main(String args[]) <BR><BR>Q19 <BR>Under which 
circumstances will a thread stop? <BR><BR>1) The method waitforId() in class 
MediaTracker is called. <BR>2) The run() method that the thread is executing 
ends. <BR>3) The call to the start() method of the Thread object returns. <BR>4) 
The suspend() method is called on the Thread object. <BR>5) The wait() method is 
called on the Thread object. <BR><BR>Q20 <BR>When creating a class that 
associates a set of keys with a set of values, which of these interfaces is most 
applicable? <BR><BR>1) Collection <BR>2) Set <BR>3) SortedSet <BR>4) Map 
<BR><BR>Q21 <BR>What does the value returned by the method getID() found in 
class java.awt.AWTEvent uniquely identify? <BR><BR>1) The particular event 
instance. <BR>2) The source of the event. <BR>3) The set of events that were 
triggered by the same action. <BR>4) The type of event. <BR>5) The type of 
component from which the event originated. <BR><BR>Q22 <BR>What will be written 
to the standard output when the following program is run? <BR><BR>class Base { 
<BR>int i; <BR>Base() { <BR>add(1); <BR>} <BR>void add(int v) { <BR>i += v; 
<BR>} <BR>void print() { <BR>System.out.println(i); <BR>} <BR>} <BR>class 
Extension extends Base { <BR>Extension() { <BR>add(2); <BR>} <BR>void add(int v) 
{ <BR>i += v*2; <BR>} <BR>} <BR>public class Qd073 { <BR>public static void 
main(String args[]) { <BR>bogo(new Extension()); <BR>} <BR>static void bogo(Base 
b) { <BR>b.add(8); <BR>b.print(); <BR>} <BR>} <BR><BR>1) 9 <BR>2) 18 <BR>3) 20 
<BR>4) 21 <BR>5) 22 <BR><BR>Q23 <BR>Which lines of code are valid declarations 
of a native method when occurring within the declaration of the following class? 
<BR><BR>public class Qf575 { <BR>// insert declaration of a native method here 
<BR>} <BR><BR>1) native public void setTemperature(int kelvin); <BR>2) private 
native void setTemperature(int kelvin); <BR>3) protected int native 
getTemperature(); <BR>4) public abstract native void setTemperature(int kelvin); 
<BR>5) native int setTemperature(int kelvin) {} <BR><BR>Q24 <BR>How does the 
weighty property of the GridBagConstraints objects used in grid bag layout 
affect the layout of the components? <BR><BR>1) It affects which grid cell the 
components end up in. <BR>2) It affects how the extra vertical space is 
distributed. <BR>3) It affects the alignment of each component. <BR>4) It 
affects whether the components completely fill their allotted display area 
vertically. <BR><BR>Q25 <BR>Which statements can be inserted at the indicated 
position in the following code to make the program write 1 on the standard 
output when run? <BR><BR>public class Q4a39 { <BR>int a = 1; <BR>int b = 1; 
<BR>int c = 1; <BR>class Inner { <BR>int a = 2; <BR>int get() { <BR>int c = 3; 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -