aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes K&B doubt(unofficial errata)  Moderators,Please keep this thread on the top so all to see and add Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of JavaScript Promises Essentials this week in the JavaScript forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "K&B doubt(unofficial errata)  Moderators,Please keep this thread on the top so all to see and add " Watch "K&B doubt(unofficial errata)  Moderators,Please keep this thread on the top so all to see and add " New topic
Author

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

Meherdad Bomanbehram
Ranch Hand

Joined: May 28, 2007
Posts: 140

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.


Aashu Mahajan
Ranch Hand

Joined: May 27, 2011
Posts: 114

@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

Joined: May 28, 2007
Posts: 140

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
ayush kulshrestha
Greenhorn

Joined: May 27, 2011
Posts: 13
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 agree. Here's the link: http://aspose.com/file-tools
 
subject: K&B doubt(unofficial errata) Moderators,Please keep this thread on the top so all to see and add