Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring 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

Jeanne Boyarsky - Assessment Test - Question 14

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Below is Question 14 from "Jeanne Boyarsky" book Assessment Test at page xxxvii. I do not understand which object can replace line 5 (blank line) to compile and execute code successfully.

Q.14. Assuming we have a valid, non-null HenHouse object whose value is initialized by the
blank line shown here, which of the following are possible outputs of this application?
(Choose all that apply)

A. The code will not compile because of line 6.
B. The code will not compile because of lines 7–8.
C. The application will compile but not produce any output.
D. The application will output Cluck exactly once.
E. The application will output Cluck more than once.
F. The application will compile but produce an exception at runtime.

Correct Answer: DEF


Thanks!
 
Sheriff
Posts: 7108
184
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm thinking that you would pass a List via the constructor.  What do you think?  How would that work?
 
Bartender
Posts: 3323
86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

jnrohit Jain wrote:I do not understand which object can replace line 5 (blank line) to compile and execute code successfully.


Whatever object you create has to be assignable to a variable of type HenHouse. Are there any classes given that can be assigned to a variable of type HenHouse, if not can you create one?
 
Sheriff
Posts: 7647
522
Mac OS X VI Editor BSD Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

jnrohit Jain wrote: I do not understand which object can replace line 5 (blank line) to compile and execute code successfully.

The one, which implements HenHouse interface. However, this question isn't about that as book authors let you assume all is fine with that particular line in order to shorten code and train you on the particular topic this question is meant to test.

However, given answers as correct ones are correct.

Tricky part could be to understand what this question is asking by not reading it carefully. Exam also contains questions to which not paying careful attention could give an unexpected outcome.

which of the following are possible outputs of this application?

You need to read this question, on any possible input, what are the all possible outcomes?
 
Liutauras Vilda
Sheriff
Posts: 7647
522
Mac OS X VI Editor BSD Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Think, what this line can give you as a returned value? Maybe returned but not much in there? Maybe nothing returned at all in some cases?
 
Beware the other head of science - it bites! Nibble on this message:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic