aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Label, Continue, Break Mock Question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Label, Continue, Break Mock Question" Watch "Label, Continue, Break Mock Question" New topic
Author

Label, Continue, Break Mock Question

Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

Here are two mock questions for you.



1). Given:

What is the result?

a). 010123
b). 001123
c). 012013
d). 01Nine0123
e). 0120134Nine56789
f). 0120134Nine


2). Given:

What is the result?

a). Does not compile.

b). Processing
0Before Continue
Processing
1Before Continue
Processing
2Before Continue
Processing
3Before Break
Some More Processing
Processing
4Before Continue

c). Processing
0Before Break
Processing
1Before Break
Processing
2Before Break
Processing
3Before Continue
Some More Processing
Processing
4Before Break

d). Processing
0Before Continue
Some More Processing
Processing
1Before Continue
Some More Processing
Processing
2Before Continue
Some More Processing
Processing
3Before Break
Processing
4Before Continue
Some More Processing


e). An Exception is thrown.




Good Luck

Mark
[ January 17, 2005: Message edited by: Mark Spritzler ]

Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Mike Gershman
Ranch Hand

Joined: Mar 13, 2004
Posts: 1272
Mark:

Were these questions not supposed to be indented? That's cruel.


Mike Gershman
SCJP 1.4, SCWCD in process
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

Aww man, me of all people not using the CODE tags.

Just Shoot me.

Mark
Poonam Advani
Ranch Hand

Joined: Aug 25, 2004
Posts: 38
I think the answer for the first one is "c" i.e. it prints 012013.
Swapan Mazumdar
Ranch Hand

Joined: Jul 23, 2003
Posts: 83
Hi Mark,

I liked your mock Qs. especially the second question was very much twisted. Referring to this question can body explain why
doesn't execute the for loop(coded below) again and again forming an infinite loop

Can any body comment on this issue.
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
"Can anybody comment on this issue."

It's because the continue is taking you to the ++k and the condition k < 5 is then tried.
[ January 18, 2005: Message edited by: Barry Gaunt ]

Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
shri mon
Ranch Hand

Joined: Jan 11, 2005
Posts: 63
continue does not reset the loop variable.
It will just stop the current iteration and continue with the next one.
sabah ammar
Greenhorn

Joined: Jan 10, 2005
Posts: 23
just check the max matching executions and use method of elimination for the first answer
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Label, Continue, Break Mock Question
 
Similar Threads
Flow Control.......
loop question with labeled continue
Alone I do not obtain.....
plz exaplin me this Prog
three for Loops?