This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Mind Q 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 "Mind Q" Watch "Mind Q" New topic
Author

Mind Q

Hemant Bhaiya
Greenhorn

Joined: Nov 01, 2000
Posts: 21
Can someone clear me the answer for the following question:
Assume that val has been defined as an int for the code below:
if( val > 4 )
{ System.out.println( "Test A" );
}
else if( val > 9 )
{ System.out.println( "Test B" );
}
else System.out.println( "Test C" );
Which values of val will result in "Test C" being printed:
a) val < 0 <br /> b) val between 0 and 4 <br /> c) val between 4 and 9 <br /> d) val > 9
e) val = 0
f) no values for val will be satisfactory
regards,
Hemant
Serge Plourde
Ranch Hand

Joined: Jun 23, 2000
Posts: 140
Hi Hemant, the answer is a, b, and e. And you can test it with the following piece of code, which is mostly copied from your question. The only addition is the handling of a parameter that will allow you to test the answers:

I don't see the point of this question though. The answer was quite straightfoward to find.
------------------
Hope this helps.
Have a good day.
[This message has been edited by Serge Plourde (edited November 23, 2000).]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Mind Q
 
Similar Threads
Another Tricky one
I cant believe my eyes?
if and else
If
method..