Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Label, Continue, Break Mock Question

 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Mike Gershman
Ranch Hand
Posts: 1272
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mark:

Were these questions not supposed to be indented? That's cruel.
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Aww man, me of all people not using the CODE tags.

Just Shoot me.

Mark
 
Poonam Advani
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think the answer for the first one is "c" i.e. it prints 012013.
 
Swapan Mazumdar
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 7729
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"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 ]
 
shri mon
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
continue does not reset the loop variable.
It will just stop the current iteration and continue with the next one.
 
sabah ammar
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
just check the max matching executions and use method of elimination for the first answer
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic