IB Computer Science Exam            Friday 9 June, 2006        9:30-11:30        by Mr Mulkey  

Write ALL answers on the lined-paper provided - do not write answers on the exam paper.
Number all answers and write clearly.  Always write the best answer you can (within time limits),
writing clearly and exactly.


Write a short answer (at most a few words) for each question.          (10 marks)

  1. How many bits are there in one byte?
  2. How many bytes are there in one kilobyte?
  3. What do the letters in RAM stand for?
  4. What do the letters in GUI stand for?
  5. The machine instruction cycle has 4 stages.  From the following list,
       choose the four stages and write them in the correct order:
          Cache      Decode      Decrypt      Execute       Fetch       Store
  6. How many bits are there in an IP address?
  7. Write the decimal number 99 in binary.
  8. Write the decimal number  -99  as an 8-bit binary number, using two's complement
  9. Calculate the approximate number of Megabytes in a 2 GigaByte USB Memory Stick.
  10. State the Big-O efficency of a bubble-sort algorithm.

Answer TRUE or FALSE to each of the following:                          (10 marks)

  1. Moore's Law says that the density of transistors in microprocessors
    will double approximately every 18 months.
  2. Java is case-sensitive.
  3. The following code prints "Goodbye" :
        int  x = 5;
      if (x & 7 == 7)
      { System.out.println("Goodbye"); }
     
  4. Secondary memory is another name for virtual memory.
  5. A parity bit tells whether a byte is positive or negative.
  6. The Least-Significant-Bit in a byte always has a value of either 1 or 0.
  7. ABCD hex = 1010 1011 1100 1101 bin
  8. 11.11 bin  =  3.3 decimal
  9. A Java method always starts with the words:  public void ...
  10. A communication protocol is a set of rules to ensure that data is transmitted
    and received in a standardized fashion.

For the following questions, you should write several sentences for each answer.                   
For more marks, write more sentences.

21.  TRACE this algorithm and write everything that will be printed.         {3 marks}

22.  Explain the difference between parallel arrays and a 2-dimensional array.    {4 marks}
        
Include a diagram or example(s) in your answer.

23.  (a) Outline two differences between a desktop PC and a pocket PC             {2 marks}
               that shows they are different platforms.  
       
(b) Explain the relationship(s) between CPU, cache memory, and RAM.       {3 marks}

24.  Add the following binary numbers together:   01010011 + 00101010 ,              {3 marks}
       and write your answer in binary.  Show your work if possible.

25.  Write a Java method that accepts 3 numbers as parameters,                         {5 marks}
       decides which of the numbers is the largest, and returns that number.  


26.  Assume that a Java program is supposed to input a user's e-mail address.  
       The address will be input as follows:   String  email = input("E-mail address:");
       The address should look something like this:   username@server.com

     (a)  Explain the difference between validating and verifying user input.
           Decide which is more appropriate for checking the e-mail address and explain why.   {4 marks}

    (b)  Write a single Java command to change the e-mail address to all CAPITALS.             {2 marks}

     (c)  Write a method to check whether the user has typed a reasonable address.
           Your method should check that:
               (i) the address contains the '@' character
              (ii) the address contains a period and it is after the '@' character
             (iii) there are at least 2 characters between the '@' and the period
             (iv) there are at least 3 characters following the period
           The method should return true if the address is okay - otherwise return false.           {11 marks}
      
    (d)  Describe how a computer can find the correct IP address to use when
           sending an e-mail, assuming it already has the e-mail address.                                  {3 marks}


27. (a) Outline how steganography can be used to hide secret messages in a picture.     {3 marks}
      
(b) Explain why the same process could not be used to hide secret messages
            inside a text file - for example, in an e-mail.                                                          {2 marks}

28.  This question is all about errors.

    (a)  Write a clear, complete, technical definition of the term error.                             {3 marks}

    (b) Explain the difference between a syntax error and a logic error in a Java program. {3 marks}

    (c)  Explain how parity checks work, including:
            (i)  the difference between even and odd parity
           (ii)  how parity is calculated
          (iii)  what kind of data can be checked this way.                                                     {5 marks}

    (c)  Explain the role of the sender address and a check-sum in handling errors
          in packets transmitted through the Internet.                                                             {4 marks}          


29.  The following method writes numbers into a RandomAccessFile.

   public void saveNumbers()
   {
      try
      {  RandomAccessFile data = new RandomAccessFile("nums.dat","rw");
int pos = 0;
double num = 77;
         while (num > 0)
{
num = inputDouble("Type a positive number(0 to quit):");

data.seek(10*pos);
data.writeDouble(num);

pos = pos + 1;
}
         data.close();
      }
      catch(IOException ex) { output(ex.toString()); }         
   }

     (a) Explain why the number 77 will probably not be the first number in the file.     {2 marks}

     (b) Explain the meaning of the command:   data.seek(10*pos);                             {2 marks}

     (c)  Assume the user has typed 50 numbers into the file.  Write a method to copy all the numbers
           back out of the file and store them inside an array named numbers[].                 {8 marks}

     (d)  Assume the array numbers[] contains 50 numbers.  Write a method called sort that will sort
           the numbers into descending order, placing the largest numbers at the beginning of the list
           and the smallest numbers at the end of the list.                                                  {8 marks} 


 30.  Assume that a user has a sequence of numbers, such as:    

               1    8    15    22    29  ....              or              10     20     40    80     160   ......

        They want a program that will predict the next number in the sequence.

(a)  Write a method that will input the sequence of numbers and store these numbers in an array..
      Assume that the user will always type 5 numbers.
      The stored data will be used in the  next method (below) .                                     {5 marks}

(b)  Assume the user has typed in 5 numbers and they have been stored (using part (a) above).
      Write a method to calculate the differences between each pair of numbers,
       producing results like these:

Sequence:           1      8    15    22    29             or            10     20     40    80     160   ......
  Differences:         7      7      7      7                                      10     20     40     80

      The differences (second row) should be stored in an appropriate data-structure -
       you can decide how that happens - the data must be stored so that it can be used
       in the next method (below).                                                                                      {5 marks}

(c)  Assume the method in part (b) (above) has already run, and the differences have been stored.
      Now write a method that will examine the differences (e.g. 7, 7, 7, 7)  and check whether they
      are ALL EQUAL.  If the differences are all equal, the method should calculate the next number
      
of the sequence.  Then it should place the number into the array containing the original sequence,
      in the next position. If the differences are not all equal,  the method  should place -1 into the array,
      in the next position following the original numbers.  

     For example:   1      8    15    22    29   36          or            10     20     40    80     160    -1

                                                                                                                                         {6 marks}

(d)  In clear, precise English (don't write Java code), outline the changes/improvements
      needed in these methods so the user does not need to type exactly 5 numbers - e.g. they might
      type only 3 or 4 numbers, or they might type 6 or 7 or more numbers.                  {4 marks}
 

 

 

IB Computer Science yr 1      Final Exam    9 June 2006

      by  Dave Mulkey    

Length:   2 hours

Instructions -

The HL and SL students all take the same exam.

They are NOT permitted to use calculators.

Writing paper is attached.  All answers must be written on the lined answer pages.

Please remind them to write their name on the answer pages.

Here are the names of the 10 students: