• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Jj Roberts
  • Carey Brown
Bartenders:
  • salvin francis
  • Frits Walraven
  • Piet Souris

a question for "For loop".

 
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
 
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 ]
 
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
 
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 ]
 
I think I'll just lie down here for a second. And ponder this tiny ad:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic