aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes valiveru mock exam errata, please explain correct answers... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "valiveru mock exam errata, please explain correct answers..." Watch "valiveru mock exam errata, please explain correct answers..." New topic
Author

valiveru mock exam errata, please explain correct answers...

sarim raza
Ranch Hand

Joined: Nov 02, 2000
Posts: 232
Which one of these will compile and run ?
A.import java.awt.Button;
import java.lang.Runnable;
public class MyClass extends Button implements Runnable{
public void run(){
//Some valid Code
}
}
//ANSWER IS D AND A BUT I CHOSE
B.import java.awt.event.*;
import java.applet.Applet;

public class MyApplet extends Applet,WindowAdapter{
public void windowClosed(WindowEvent we){
//Some Valid Code
}
}
C.import java.lang.Runnable;

public class MyClass implements Runnable{
public void run(){
int i = 10
System.out.println("i = "+i);
}
}
D.import java.awt.event.*;
public class MyClass extends WindowAdapter
implements WindowListener{
public void windowClosed(WindowEvent we){
//Some Valid Code
}
}
//ANSWER IS A AND D, BUT I SAW NOTHING WRONG WITH C??

Question 19.
Given the code
1public class ThreadDemo extends Thread{
2 public void run(){
3System.out.println("Thread Started");
4//What Code ???
5 System.out.println("Done");
6 }
7 public static void main(String[] arg){
8ThreadDemo td = new ThreadDemo();
9td.start();
10 }
11}
Which of the following given code segment(s) below can be placed at line 4 to print both "Thread Started" and "Done" to the standard output.

A.suspend(); resume();
B.sleep(10000);
C.yield();
D.yield(); resume();
E.All the above

//ANSWER IS C AND D, BUT HOW CAN D WORK ? I THOUGHT RESUME ONLY WORKS WITH SUSPEND ?
sunilkumar ssuparasmul
Ranch Hand

Joined: Dec 13, 2000
Posts: 142
for u r 1 ques i guess C is also correct .bcos there is nothing wrong in what he has specified except for a missing semicolon after int i=10 but that would not be a reason
For u r second q ,thought resume works only with suspend , in this case it will ignore the call so it will print whatever folows. BUT I HAVE A DOUBT , y is B not correct .after 10 seconds wont it execute and print .idf not y.?


"Winners don't do different things<br /> They do things differently"
bill bozeman
Ranch Hand

Joined: Jun 30, 2000
Posts: 1070
sunilkumar and sarim,
In the first question, C is not correct because there is no semicolon after int i = 10. Compiler will complain, so C is not correct. So the correct answers are A and D
In the second question, sleep(10000) cannot be placed in the code because sleep has to catch InterruptedException and in this code it does not. So the correct answers are C and D. Also, resume() has been deprecated, so the new exam shouldn't ask any questions on this.
bill
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: valiveru mock exam errata, please explain correct answers...
 
Similar Threads
Listeners and Adupters
Class declarations
Listeners and Adupters
Another Mock Exam Question
Another Mock Exam Question