This week's book giveaway is in the Jython/Python forum.
We're giving away four copies of Hands On Software Engineering with Python and have Brian Allbey on-line!
See this thread for details.
Win a copy of Hands On Software Engineering with Python this week in the Jython/Python 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
  • Jeanne Boyarsky
  • Bear Bibeault
  • Knute Snortum
  • Liutauras Vilda
Sheriffs:
  • Tim Cooke
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Ron McLeod
  • Ganesh Patekar
  • salvin francis
Bartenders:
  • Tim Holloway
  • Carey Brown
  • Stephan van Hulst

Roberts/Heller/Ernest Ch. 6 questions 1 & 2 (pp. 192-3)  RSS feed

 
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Roberts/Heller/Ernest Ch. 6 questions 1 & 2 (pp. 192-3):
I'm not going to bother typing in both questions, but they both ask about lists of possible function declarations (either overloads or overrides), and ask which ones are legal. An example is:
<code><pre>A. public int aMethod(int a, int b) { }</pre></code>
All the given answers for both questions are incorrect, because all the methods are declared with non-void return types, yet none of the methods contains a return statement. In order for the given answers to make sense, pretend that each method contains a "return 0;", as in:
<code><pre>A. public int aMethod(int a, int b) { return 0; }</pre></code>
(or some other code, any other code as long as it contains a return using a suitable data type.)
This may be an obvious error such that people can easily tell what RHE really meant by the question, but it annoys me that I told them about this 3 reprintings ago, yet they still haven't included it in their errata.
 
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jim
Thanks for observing it and bringing it to everyone's notice. That was a sharp observation but it helps us to keep this point in mind in the real exam.
Thanks.
 
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jim,
I agree with you. If you don't specify the return statement with the suitable return type, it won't compile. But if this type of Question comes in the exam, how can we be sure that it's not asking us to test for the suitable modifiers, position of the return type etc. If we are asked to choose the legal method definitions, should we not pick this one?.
public int aMethod(int a){}
Can you please clear my doubt regarding this.
Regards,
Kiran.
 
Squanch that. And squanch this tiny ad:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database
https://coderanch.com/t/704633/RavenDB-Open-Source-NoSQL-Database
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!