1) If a two's
compliment procedure was applied to the
following byte, which of the following numbers would
be generated.
00001001 // binary representation of an byte
a) -9
b) -10
c) -7
d)
-8
( a )
2) Which of the
following types must be suffixed with a letter
or
otherwise will default to another values.
a ) byte
b ) char
c ) double
d )
long
( d )
3) True or False. Boolean cannot be assigned
but may be
cast to the char type. True /
False ( false )
4) True or False. A byte may be assigned to a char type
True / False
( false )
5) Which of the following can represent
the largest number.
a ) float
b ) int
c ) long
d )
char
( a )
6) True or False. The following will
compile. True / False
float f =
654.3;
( false )
7) Using the following variables in
assignment, which of the
following assignments will not
compile.
char c= ' x ' ;
short s = 3;
byte b = 2;
int i = 4;
a) s =
b;
b) i = c;
c) s = c;
d) i = s;
( c )
8 ) Using the following variables in
assignment, which of the following casts
will not compile?
( Try and answer these first from your understanding.
Then test your
answers by compiling inside a main method.)
short s =223;
double d = 333.08;
int i = 412;
boolean boo;
char c=' ';
a) s = (short) d;
b) c = (byte ) i;
c) s = (byte) i;
d) i = (int) s;
( b )
9) Which of the following types is needed to store the results of the following exrpression.
short s = 21983;
double d = 22;
___ variable = s + d;
a) float
b) short
c) int
d)
double
( d )
10) The number in
the following expression, ( 890 + " skiers " ) is
promoted which
of the following types.
a) short
b) int
c) String
d)
char
( c )