SCJP试题-SCJPMockExam1

来源:java认证发布时间:2012-11-12 12:48:18java认证视频


Q5
An instance member…

1) is also called a static member
2) is always a variable
3) is never a method
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 other's member variables
2) They pass messages by modifying the static member variables of each other's classes
3) They pass messages by calling each other's instance member methods
4) They pass messages by calling static member methods of each other's 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 superclass 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 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 class 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 result 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 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 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 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.

视频学习

我考网版权与免责声明

① 凡本网注明稿件来源为"原创"的所有文字、图片和音视频稿件,版权均属本网所有。任何媒体、网站或个人转载、链接转贴或以其他方式复制发表时必须注明"稿件来源:我考网",违者本网将依法追究责任;

② 本网部分稿件来源于网络,任何单位或个人认为我考网发布的内容可能涉嫌侵犯其合法权益,应该及时向我考网书面反馈,并提供身份证明、权属证明及详细侵权情况证明,我考网在收到上述法律文件后,将会尽快移除被控侵权内容。

最近更新

社区交流

考试问答