Hi All,
Iam unable to solve the following ques please help me.Iam plamming to tkae scjp5 within a week iam unable to find mock ques related to reg expression.
thanks in advance
sankar
Question 13: There are a number of labels in the source code below. These are labeled a through j. Which label identifies the earliest point where, after that line has executed, the object referred to by the variable first may be garbage collected? class Riddle {
public static void main(
String[] args) {
String first, second;
String riddle;
if (args.length < 2)
return; a: first = new String(args[0]);
b: second = new String(args[1]);
c: riddle = "When is a " + first;
d: first = null;
e: riddle += " like a " + second + "?";
f: second = null;
g: System.out.println(riddle);
h: args[0] = null;
i: args[1] = null;
j:
}
}
Select the one right answer.
d:
e:
h:
i:
j:
Question 46: If you supply a target object when you create a new
Thread, as in: Thread t = new Thread(targetObject);
What
test of instanceof does targetObject have to pass for this to be legal?
Select the one right answer.
targetObject instanceof Thread
targetObject instanceof Object
targetObject instanceof
Applet targetObject instanceof Runnable
targetObject instanceof String
Question 47: What appears in the standard output when you run the Dots class?
class Dots implements Runnable {
DotThread t;
public static void main(String[] args) {
Dots d = new Dots();
d.t = new DotThread();
}
public void init() {
t.start();
t = new DashThread().start();
}
}
class DotThread extends Thread {
public void run() {
for (int index = 0; index < 100; index++)
System.out.print(".");
}
}
class DashThread extends Thread {
public void run() {
for (int index = 0; index < 100; index++)
System.out.print("-");
}
}
nothing
100 dots (.)
200 dots (.)
100 dashes (-)
100 dots (.) and 100 dashes(-)
Question 55: What will happen when you attempt to compile and run the following program by passing the Test class to the
Java interpreter? class Test {
public static void main() {
System.out.println("hello");
}
}
Select the one right answer.
The program does not compile because main() is not defined correctly.
The program compiles but when you try to run the interpreter complains that it cannot find the main() method it needs to run.
The program compiles but you cannot run it because the class is not declared as public.
The program compiles and runs without an error but does not display anything in the standard output.
The program compiles and displays "hello" in the standard output when you run it.