wood burning stoves 2.0*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes A tough one - on flow control 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 "A tough one - on flow control" Watch "A tough one - on flow control" New topic
Author

A tough one - on flow control

Shailendra Guggali
Ranch Hand

Joined: Feb 01, 2001
Posts: 86
try the foll code :
class TeastClass
{
public static void main(String args[ ] )
{
int k = 0; int m = 0;
for ( int i = 0; i <= 3; i++)
{
k++;
if ( i == 2)
{
// line 1
}
m++;
}
System.out.println( k + ", " + m );
}
}
// which statements are correct when inserted at line //1
// 1. break; will print 3,2
// 2. continue; will print 4,3
// 3. i = 4; will print 3,3
// 4. continue; will print 3,2
// 5. i = m++; will print 4,4
natarajan meghanathan
Ranch Hand

Joined: Feb 01, 2001
Posts: 130
I don't think it is tough. basically u have to plug and play each option. Options 1,2,3 are correct.
option 5 is little bit catchy. but it will print 4,5 not 4,4. thats the only thing u need to be careful.

Sun Certified Programmer for Java 2 Platform
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: A tough one - on flow control
 
Similar Threads
The i++ operator
Val's Exam Question numer 54
Question from jqplus
what is the Output? and why?
break and continue stmts