File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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 Android Security Essentials Live Lessons this week in the Android 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).]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Mind Q
 
Similar Threads
method..
If
I cant believe my eyes?
Another Tricky one
if and else