wood burning stoves 2.0
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes valiveru exam errata - please confirm  REAL answers, thanks! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "valiveru exam errata - please confirm  REAL answers, thanks!" Watch "valiveru exam errata - please confirm  REAL answers, thanks!" New topic

valiveru exam errata - please confirm REAL answers, thanks!

sarim raza
Ranch Hand

Joined: Nov 02, 2000
Posts: 232
Question 18.
Given the code below
public class ThreadDemo extends Thread[
public void run(){
System.out.println("Thread started");
Thread.sleep(20000); //20 seconds sleep
System.out.println("I am Back from my sleep");
catch(InterruptedException e){
System.out.println("I got Interrupted");
Which of the following statements are true?

A.Exactly 20 seconds after the start method
is called "I am Back from my sleep" be printed.
B.We can be sure that atleast after 20 seconds elapsed,
"I am Back from sleep" will be printed.
C.The delay between output "Thread started" and "I am Back
from sleep" is less or more than 20 seconds.
D.None of the above.
//I CHOSE D, SINCE THERE IS NO start() method invocation, how can run() be invoked ??
Given the following code segments, select the ones that are legal.
A.boolean b = true;
int i = 10;
String s = b + i;
B.char c = 10;
int i = 20;
c += i;
C.String s = "Hello" ;
int i = 10;
i += s;
D.boolean b = null ;
if( b == null ){};
E.String s = "Hello" ;
int i = 10;
s += i;
F.Integer ii = new Integer(10);
int i = 10;
ii += i;
vadiraj vd
Ranch Hand

Joined: Dec 15, 2000
Posts: 68
For your first question I think the answer B is correct.
Here you are creating your own thread extending Thread class. You are going to create an object on this class(ThreadDemo) and call start() method.
Regarding my answer, the thread goes to sleep for atleast the specified interval. When it comes back there is a chance that a higher priority thread is running and this thread is put into the ready queue. So we can be sure that the thread sleeps for atleast the specified interval.

For your second question, the extended assignment operators have the cast built-in. so,
1. char c = 10;
2. int i = 20;
3. c += i;
is valid. At line 3, the += operator will do a implicit conversion from int to char and assigns the value to c.
Hope this helps.

Regards<BR>---------<BR>vadiraj<P><BR>*****************<BR>There's a lot of I in J.<BR>*****************
sarim raza
Ranch Hand

Joined: Nov 02, 2000
Posts: 232
thanks a lot, that was so helpful !
appreciate it!
sunilkumar ssuparasmul
Ranch Hand

Joined: Dec 13, 2000
Posts: 142
for the second case
the type casting is done bcos char is unsigned so the range of char is lies within int since it is signed so implicit type casting is done.

"Winners don't do different things<br /> They do things differently"
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
subject: valiveru exam errata - please confirm REAL answers, thanks!
jQuery in Action, 3rd edition