Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

k&b page 312

 
Allen Bandela
Ranch Hand
Posts: 128
Eclipse IDE MS IE Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
is'nt there a mistake on page 313 of K&B SCJP5?
Specifically the program with fragments. Isnt the output 41? or i'm missing something?
 
Loveen Jain
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


I think you are talking about this code right?

Answer is certainly 4 2.

Reason :
a) First print statement : 14 % 5 = 4 ( is the remainder after divison of 14 by 5)
b) Second print statement : 7 % 5 = 2 ( is the remainder after divison of 7 by 5).

I hope its clear!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic