• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

K&B doubt(unofficial errata) Moderators,Please keep this thread on the top so all to see and add

 
Ranch Hand
Posts: 142
Netbeans IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Moderators, could you Please keep this thread on the top so all others could post their error findings too on this thread Many Thanks

Chapter 4 self test question 3


And the command-line invocation:
java Fork live2
What is the result?
A. test case
B. production live2
C. test case live2
D. Compilation fails
E. An exception is thrown at runtime
Answer:
✓ E is correct. Because the short circuit (||) is not used, both operands are evaluated. Since
args[1] is past the args array bounds, an ArrayIndexOutOfBoundsException is thrown.
A, B, C, and D are incorrect based on the above. (Objective 7.6)



The actual answer is not compilation error as given in the book it is "Production Fork " this option is not available in the valid options.


 
Ranch Hand
Posts: 114
Eclipse IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
@MeHerDad BoManBehRam

The Correct ans. to this Question is option 'E'.

And why should "Production Fork"' include in the option. Its doesn't matter it is include or not because the answere is 'E'.
 
Meherdad Bomanbehram
Ranch Hand
Posts: 142
Netbeans IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Page 281 chapter 3 self test question 7


7. Given:
3. public class Bridge {
4. public enum Suits {
5. CLUBS(20), DIAMONDS(20), HEARTS(30), SPADES(30),
6. NOTRUMP(40) { public int getValue(int bid) {
return ((bid-1)*30)+40; } };
7. Suits(int points) { this.points = points; }
8. private int points;
9. public int getValue(int bid) { return points * bid; }
10. }
11. public static void main(String[] args) {
12. System.out.println(Suits.NOTRUMP.getBidValue(3));
13. System.out.println(Suits.SPADES + " " + Suits.SPADES.points);
14. System.out.println(Suits.values());
15. }
16. }
Which are true? (Choose all that apply.)
A. The output could contain 30
B. The output could contain @bf73fa
C. The output could contain DIAMONDS
D. Compilation fails due to an error on line 6
E. Compilation fails due to an error on line 7
F. Compilation fails due to an error on line 8
G. Compilation fails due to an error on line 9
H. Compilation fails due to an error within lines 12 to 14
Answer:
® ✓ A and B are correct. The code compiles and runs without exception. The values()
method returns an array reference, not the contents of the enum, so DIAMONDS is never
printed.
®˚ C, D, E, F, G, and H are incorrect based on the above. (Objective 1.3)



The actual answer is Compilation fails on line 12 as there is no method getBidValue(int) so the correct option should be H or change the program to be getVaule(int) on line 12 or change line 6 and line 9 to be getBidValue(int) then the correct answer would be A and B
 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
mr .MeHerDad BoManBehRam
the answer to your q is simple
you are confusing with thee command line arguments
here in the args[] the name of the file is not included
so it will be live2
instead of fork live2 in case which your answer was correct
if it was the case of c/c++ your answer weould have been correct
 
I'm still in control here. LOOK at this tiny ad!
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic