Review Sheet - Introduction to Programming | COMP 110, Study notes of Computer Science

Material Type: Notes; Class: Introduction to Programming; Subject: COMPUTER SCIENCE; University: University of North Carolina - Chapel Hill; Term: Fall 2008;

Typology: Study notes

Pre 2010

Uploaded on 03/11/2009

koofers-user-wdv-1
koofers-user-wdv-1 🇺🇸

8 documents

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
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
pf2

Partial preview of the text

Download Review Sheet - Introduction to Programming | COMP 110 and more Study notes Computer Science in PDF only on Docsity!

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.
  7. What data value is stored in myDouble now? double myDouble = ( 1.0 / 2.0 ) * 5.0; 2.
  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
  1. Suppose that mary is an object of class Person, and suppose that increaseAge is a method of class Person that uses one argument, an integer. Write the invocation of the method increaseAge for the object mary using the argument 5. mary.increaseAge(5);
  2. 5 % 2 = 1 12 % 4 = 0 82 % 60 = 22 24 % 14 = 10
  3. What is the value of myInt after each line of code is excuted? 0 int myInt = 0; 1 myInt++; 6 myInt = myInt + 5; 3 myInt -= 3; 3 System.out.println(“the value Is:”, myInt);
  4. What kind of error would you get from the following line of code? How would you fix it? byte myByte = 5 Syntax error. More specifically, you might see: ‘;’ expected. Add a semicolon to the end of the line.
  5. What are the values of the variables n and m after executing the following code? int n, m, temp; n = 10; m = 20; temp = n; n = m; m = temp; n: 20 m: 10
  6. Is there anything I could change about this course that would be helpful to you?