• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

a question for "For loop".

 
sura watthana
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 7729
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Arnab karmakar
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi sura,

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

arnab
 
Anand B Raju
Ranch Hand
Posts: 172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic