• Post Reply Bookmark Topic Watch Topic
  • New Topic

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

 
C Muntean
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]
 
Roel De Nijs
Sheriff
Posts: 11095
173
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • 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
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!