Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Failure in book Java 2 Exam Notes

 
Chris Lenz
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ISBN 0-7821-2826-2 Sybex - Philip Heller
Page 83 -> Sample Question
Which of the following Java primitive types can express negative numbers?
A boolean
B byte
C char
D float
E long
Answer: B,C,D. The boolean type is not numeric. The char type can only take zero and positive values.
Wrong, it must be answer B,D,E or?
Chris
 
John Lee
Ranch Hand
Posts: 2545
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Chris Lenz:

Which of the following Java primitive types can express negative numbers?
A boolean
B byte
C char
D float
E long

I think the answer are B,D,E.
boolean only takes 'true' and 'false'
char only takes positive.
 
John Lee
Ranch Hand
Posts: 2545
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Chris Lenz:
Which of the following Java primitive types can express negative numbers?
A boolean
B byte
C char
D float
E long

On second thought, the question asks which ... can *express* negative number.
So I think the answer are B, D, E, and C. Since people can use unicode to express negative number.
 
Dan Chisholm
Ranch Hand
Posts: 1865
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Don Liu:

On second thought, the question asks which ... can *express* negative number.
So I think the answer are B, D, E, and C. Since people can use unicode to express negative number.

Wouldn't that require at lease two characters--one character for the negative sign followed by one or more numeric characters?
 
John Lee
Ranch Hand
Posts: 2545
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Chris Lenz:
Which of the following Java primitive types can express negative numbers?
A boolean
B byte
C char
D float
E long

I see you have a point. But the question asks which primitive *type* can express negative number? So my understanding is it is not limited to one character.
If the question asks which primitive type *variable* can express negative number? then you are defintely correct.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic