?? mockcert05.txt
字號:
Mutiple: ________________
1) 1
2) 2
3) 3
4) 4
5) none
Question 58
===========================================================
What is the result of the following code :
public class SuperEx {
String r;
String s;
public SuperEx(String a,String b) {
r = a;
s = b;
}
public void aMethod() {
System.out.println("r :" + r);
}
}
public class NewSuper extends SuperEx {
public NewSuper(String a,String b) {
super(a,b);
}
public static void main(String args []) {
SuperEx a = new SuperEx("Hi","Tom");
SuperEx b = new NewSuper("Hi","Bart");
a.aMethod();
b.aMethod();
}
public void aMethod() {
System.out.println("r :" + r + " s:" + s);
}
}
Mutiple: ________________
1) The following is displayed:
r:Hi
s:Hi
2) Compiler error at the line "SuperEx b = new NewSuper("Hi","Bart");"
3) The following is displayed:
r:Hi
r:Hi s:Bart
4) The following is displayed
r:Hi s:Tom
r:Hi s:Bar
Question 59
===========================================================
You have a class with a certain variable and you don't want that variable to be accessible to ANY other class but your own. Your class must be sub-classable.
Which keyword do you add to the variable.
Mutiple: ________________
1) private
2) public
3) transient
4) final
5) abstract
Question 60
===========================================================
You get this description of a class :
Employee is a person. For every employee, we keep a vector with the working hours, an integer for the salary and a variable that can be true or false whether or not the employee has a company car.
Indicate which of the following would be used to define the class members.
Mutiple: ________________
1) Vector
2) Employee
3) Object
4) boolean
5) int
Question 61
===========================================================
Which line of code can be inserted in place of the comments, to perform the initialisation described by the comments:
public class T {
int r;
int s;
T(int x, int y) {
r = x;
s = y;
}
}
class S extends T {
int t;
public S(int x, int y, int z){
// insert here the code
// that would do the correct initialisation
// r= x and s= y
t=z;
}
}
Mutiple: ________________
1) T(x, y);
2) this(x, y);
3) super(x, y);
4) super(x, y, z);
5) None
Question 62
===========================================================
Suppose a MyException should be thrown if Condition() is true, which statements do you have to insert ?
1: public aMethod {
2:
3: if (Condition) {
4:
5: }
6:
7: }
Mutiple: ________________
1) throw new Exception() at line 4
2) throws new MyException() at line 4
3) throw new MyException() at line 6
4) throws new Exception() at line 2
5) throws MyException at line 1
Question 63
===========================================================
Given the following class definition:
class A {
protected int i;
A(int i) {
this.i = i;
}
}
Which of the following would be a valid inner class for this class?
Select all valid answers.
Mutiple: ________________
1) class B {}
2) class B extends A {}
3) class B {
B() {
System.out.println("i = " + i);
}
}
4) class B {
class A {}
}
5) class A {}
Question 64
===========================================================
What statements are true concerning the method notify() that is used in conjunction with wait()?
Select all valid answers.
Mutiple: ________________
1) if there is more than one thread waiting on a condition, only the thread that has been waiting the longest is notified
2) if there is more than one thread waiting on a condition,there is no way to predict which thread will be notifed
3) notify() is defined in the Thread class
4) it is not strictly necessary to own the lock for the object you invoke notify() for
5) notify() should only be invoked from within a while loop
Question 65
===========================================================
Given the following class:
class Counter {
public int startHere = 1;
public int endHere = 100;
public static void main(String[] args) {
new Counter().go();
}
void go() {
// A
Thread t = new Thread(a);
t.start();
}
}
What block of code can you replace at line A above so that this program will count from startHere to endHere?
Select all valid answers.
Mutiple: ________________
1) Runnable a = new Runnable() {
public void run() {
for (int i = startHere; i <= endHere; i++) {
System.out.println(i);
}
}
};
2) a implements Runnable {
public void run() {
for (int i = startHere; i <= endHere; i++) {
System.out.println(i);
}
}
};
3) Thread a = new Thread() {
public void run() {
for (int i = startHere; i <= endHere; i++) {
System.out.println(i);
}
}
};
Question 66
===========================================================
What is written to the standard output given the following statement:
System.out.println(4 | 7);
Select the one right answer.
Mutiple: ________________
1) 4
2) 5
3) 6
4) 7
5) 0
Question 67
===========================================================
Given the following class:
class Counter {
public static void main(String[] args) {
Thread t = new Thread(new CounterBehavior());
t.start();
}
}
Which of the following is a valid definition of CounterBehavior that would make Counter抯 main() method count from 1 to 100, counting once per second?
Select the one right answer.
Mutiple: ________________
1) This class is an inner class to Counter:
class CounterBehavior {
for (int i = 1; i <= 100; i++);
try {
System.out.println(i);
Thread.sleep(1000);
} catch (InterruptedException x) {}
}
}
2) This class is an inner class to Counter:
class CounterBehavior implements Runnable {
public void run() {
for (int i = 1; i <= 100; i++);
try {
System.out.println(i);
Thread.sleep(1000);
} catch (InterruptedException x) {}
}
}
}
3) This class is a top-level class:
static class CounterBehavior implements Runnable {
public void run() {
try {
for (int i = 1; i <= 100; i++) {
System.out.println(i);
Thread.sleep(1000);
}
} catch (InterruptedException x) {}
}
}
Question 68
===========================================================
Given the following class definition:
class A {
public int x;
private int y;
class B {
protected void method1() {}
class C {
private void method2() {}
}
}
}
class D extends A {
public float z;
}
What can method2() access directly, without a reference to another instance?
Select all valid answers.
Mutiple: ________________
1) the variable x defined in A
2) the variable y defined in A
3) method1 defined in B
4) the variable z defined in D
Question 69
===========================================================
You have an 8-bit file using the character set defined by ISO 8859-8. You are writing an application to display this file in a TextArea. The local encoding is already set to 8859-8. How can you write a chunk of code to read the first line from this file?
You have three variables accessible to you:
myfile is the name of the file you want to read
stream is an InputStream object associated with this file
s is a String object
Select all valid answers.
Mutiple: ________________
1) InputStreamReader reader = new InputStreamReader(stream, "8859-8");
BufferedReader buffer = new BufferedReader(reader);
s = buffer.readLine();
2) InputStreamReader reader = new InputStreamReader(stream);
BufferedReader buffer = new BufferedReader(reader);
s = buffer.readLine();
3) InputStreamReader reader = new InputStreamReader(myfile, "8859-8");
BufferedReader buffer = new BufferedReader(reader);
s = buffer.readLine();
4) InputStreamReader reader = new InputStreamReader(myfile);
BufferedReader buffer = new BufferedReader(reader);
s = buffer.readLine();
5) FileReader reader = new FileReader(myfile);
BufferedReader buffer = new BufferedReader(reader);
s = buffer.readLine();
Question 70
===========================================================
How can you write a line of code for an applet抯 init() method that determines how wide the applet is?
Select all valid answers.
Mutiple: ________________
1) int width = this.getY();
2) int width = this.getSize().w;
3) int width = getSize();
4) int width = getSize().w;
5) int width = getWidth();
Question 71
===========================================================
For a variable width font, how "wide" is a TextField created using the expression:
new TextField(20)
Select the one right answer.
Mutiple: ________________
1) 20 times the average of all the characters in the font used for this TextField object
2) 20 times the width of the letter M
3) 20 times the width of the letter a
4) 20 inches
5) 20 picas
Question 72
===========================================================
Given this interface definition:
interface A {
int method1(int i);
int method2(int j);
}
which of the following classes implement this interface and is not abstract?
Select all valid answers.
Mutiple: ________________
1) class B implements A {
int method1() { }
int method2() { }
}
2) class B {
int method1(int i) { }
int method2(int j) { }
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -