
COMP110-003 (Fall 2008) Review (Chapters 1 and 2) Name: ______________________
1. How many bits are in a byte? __8_
2. The ________CPU___________ is known as “the brain” of the computer.
3. The two values of a bit are _0_ and _1_.
4. Write the line of code that would print out the line:
COMP110 is my favorite class
System.out.println(“COMP110 is my favorite class”);
5. Write down the declaration for two variables called miles and time. Declare miles as type int and
initialize it to zero. Declare time as type double and initialize it to 40.5.
int miles = 0;
double time = 40.5;
6. What data value is stored in myDouble? (remember that 1 and 2 are integers)
double myDouble = ( 1 / 2 ) * 5.0;
0.0
7. What data value is stored in myDouble now?
double myDouble = ( 1.0 / 2.0 ) * 5.0;
2.5
8. Which of the following are illegal variable names (circle them)?
myInt 3blindMice $money! __input
total-cost magicalFluffyBunnies 123 public
9. What is the output produced by the following lines of program code?
char a, b;
a = ‘b’;
System.out.println(a);
b = ‘c’;
System.out.println(b);
a = b;
System.out.println(a);
b
c
c