jQuery in Action, 2nd edition*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes question from marcus mock exam Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "question from marcus mock exam" Watch "question from marcus mock exam" New topic
Author

question from marcus mock exam

Leandro Oliveira
Ranch Hand

Joined: Nov 07, 2002
Posts: 298
The question:
Question 4)
A byte can be of what size
1) -128 to 127
2) (-2 power 8 )-1 to 2 power 8
3) -255 to 256
4)depends on the particular implementation of the Java Virtual machine
answer:
1) A byte is a signed 8 bit integer.

In my opinion to the correct answer be 1, the question should be "A byte can be of what range?"
Do you agree, is it true to say that the size of a byte is implementation dependent, but the range must be unique???
Corey McGlone
Ranch Hand

Joined: Dec 20, 2001
Posts: 3271
Originally posted by leandro oliveira:
...is it true to say that the size of a byte is implementation dependent, but the range must be unique???

The size of a byte will always be 8 bits - the Java specifications say so. In some other languages (C++, for instance), various compilers might very well use different sizes for data types, but Java doesn't do that. All compilers must compile code so that it can be understood by any JVM. Therefore, a byte will always be 1 byte.
However, I agree that the question is worded poorly. The size of a byte will always be 8 bits, the range of a byte is -128 to 127.
I hope that helps,
Corey


SCJP Tipline, etc.
Leandro Oliveira
Ranch Hand

Joined: Nov 07, 2002
Posts: 298
Thanks!!! looks clear now!
 
jQuery in Action, 2nd edition
 
subject: question from marcus mock exam
 
Similar Threads
converting C++ type struct to Java class?
Conversion of Primitives
Widening and narrowing conversion questions
float query
size of object