Win a copy of TensorFlow 2.0 in Action this week in the Artificial Intelligence and Machine Learning 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
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

Sybex CSG 11 Assessment Test Part I Q13

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
In answer to this question is mention only one correct answer with output 12, but actually if you run that code, there will be to outputs 11 and 12, as OUTER loop is execute two times.
 
Marshal
Posts: 70684
288
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

Please provide more information about the book (I presume it is Boyarsky and Selikoff), and about the question for those of us who don't have the book.
 
author & internet detective
Posts: 40241
819
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you made a typo with the brackets when typing in the example. The outer loop starts on line 5 and ends on line 12. The inner loop starts on line 6 and ends on line 12. The println is on line 13 after both loops.

Note that the outer loop doesn't have {}. Which means it is only one statement. (Which happens to be the inner loop).

And yes, I am aware this is confusing. The loop/label questions are some of my least favorite on the exam!
 
"To do good, you actually have to do something." -- Yvon Chouinard
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic