This week's book giveaway is in the HTML Pages with CSS and JavaScript forum.
We're giving away four copies of Testing JavaScript Applications and have Lucas da Costa on-line!
See this thread for details.
Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • 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
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Java OCA 8 Chapter 2 - Operators and Statements - Review Questions Ex 9 Manual question

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello   ,

I would like to ask a  question found on the OCA 8 book that I did not notice before.
At Chapter 2: Operators and Statements Review Questions Exercise 9:

How many times will the following code print "Hello World"?



I responded 10 and actually the correct answer is "The code contains an infinite loop and does not terminate".

I wanted to make sure this is the answer.
I typed the code by mistake like this:

And I got my answer, as it prints "Hello World" 10 times.

Now, sorry if the question is dumb, but what is the difference if I do this:

Because running it like this really ends up in an infinite loop.

Thanks for your help

[HENRY: Fixed Code Tags]
 
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In this topic you'll find an explanation for exactly the same question. And in this topic you'll find an extensive discussion with lots of code examples. Both are definitely worth reading!

Hope it helps!
Kind regards,
Roel
 
Their achilles heel is the noogie! Give them noogies tiny ad!
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic