aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes a question for 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 "a question for "For loop"." Watch "a question for "For loop"." New topic
Author

a question for "For loop".

sura watthana
Ranch Hand

Joined: Sep 13, 2004
Posts: 77
Hi,
please look at the question below

which one is the correct answer and what about the rest of the choices?
Thanks

Sura
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
Usually Mock Exams have their answers provided. Where exactly does this question come from?

What happens when you compile each of these expressions?
[ October 18, 2004: 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.
Arnab karmakar
Ranch Hand

Joined: Oct 04, 2004
Posts: 46
Hi sura,

Acording to me only a and d are the coorect answers.

arnab
Anand B Raju
Ranch Hand

Joined: Sep 22, 2004
Posts: 172
hello arnab,
i think u have made wrong decision in ur choices.
according to me,

choice a) is wrong because identifier 'j' is declared and initialized in "for" loop after declaring same variable 'j' inside the method before "for" loop.

choice b) is wrong because comparision part of "for" loop doesn't evaluate to a boolean value.

choice c) is correct because it follows all the rules.

choice d) is wrong because variable i is used without initializing it.

choice e) is wrong because the format of "for" loop declaration is only wrong
[ October 18, 2004: Message edited by: Anand B ]

SCJP 1.4<br /><a href="http://www.geocities.com/sunjava4u" target="_blank" rel="nofollow">SUN JAVA 4 U</a>- links and resources for SCJP aspirants
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: a question for "For loop".
 
Similar Threads
Question from jqplus
Problem with labeled break
value of i?
Euler31
for loop