aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes q from jiris.com Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "q from jiris.com" Watch "q from jiris.com" New topic
Author

q from jiris.com

JayaSiji Gopal
Ranch Hand

Joined: Sep 27, 2004
Posts: 303
What is wrong with the following code, if any?
(Select one correct answer)
--------------------------------------------------------------------------------

public class Test005
{
public static void main(String args[])
{
Thread.yield(); //1
Thread t = Thread.currentThread();
synchronized(t) { //2
t.notify(); //3
}
Object o = new Object();
System.out.println(null == o); //4
}
}


--------------------------------------------------------------------------------

A: The code does not compile due to line //1.
B: The code does not compile due to line //2.
C: The code does not compile due to line //3.
D: The code does not compile due to line //4.
E: There is nothing wrong with the code.

i answered d, since u r comparing null == o; but the correct answer is e.
can somebody plz explain.


SCJP 1.4, SCWCD 1.4<br /> <br />Thanks in advance!<br />Jayashree.
sanjeevmehra mehra
Ranch Hand

Joined: Aug 21, 2004
Posts: 75
I have not gone through the code yet my request is use code tag for posting the code, it is available just below Add Reply button, that would be helpful for all, thanks.



A: The code does not compile due to line //1.
B: The code does not compile due to line //2.
C: The code does not compile due to line //3.
D: The code does not compile due to line //4.
E: There is nothing wrong with the code.

i answered d, since u r comparing null == o; but the correct answer is e.
can somebody plz explain.


thanks & regards,<br />Sanjeev.
Nicholas Cheung
Ranch Hand

Joined: Nov 07, 2003
Posts: 4982

since u r comparing null == o

So, why I cannot do so?

Just like you will do this:

In such sense, either "true" or "false" will be printed to the standard output.

Nick


SCJP 1.2, OCP 9i DBA, SCWCD 1.3, SCJP 1.4 (SAI), SCJD 1.4, SCWCD 1.4 (Beta), ICED (IBM 287, IBM 484, IBM 486), SCMAD 1.0 (Beta), SCBCD 1.3, ICSD (IBM 288), ICDBA (IBM 700, IBM 701), SCDJWS, ICSD (IBM 348), OCP 10g DBA (Beta), SCJP 5.0 (Beta), SCJA 1.0 (Beta), MCP(70-270), SCBCD 5.0 (Beta), SCJP 6.0, SCEA for JEE5 (in progress)
sanjeevmehra mehra
Ranch Hand

Joined: Aug 21, 2004
Posts: 75
there is nothing wrong with line 4. it is comparing two values.
null == o, it will return either true or false.
== is comparison operator.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: q from jiris.com