To Notes

CSC 212 -- 2/5/08

 

Review Questions

  1. What is the output?

    Ans:
  2. Explain the difference between InsertionSort and SelectionSort.

    Ans: Insertionsort moves up array elements one by one until a slot for the next item to insert into the array is found. SelectionSort swaps the item immediately to the right of the sorted segment with the smallest element of the remaining unsorted elements.

  3. Explain how to read data from a file.

    Ans: (1) Import java.io.*, (2) declare the main method header to throw FileNotFoundException, (3) declare and instantiate a Scanner object s from a FileReader object, (3) while s.hasMoreXX (you choose XX) is true use the s.nextXX methods to read data from the file.

  4. Rewrite using only one line:

    Ans:
  5. Create an array of the 52 playing cards (poker cards without jokers). Use a nested double for loop. The constructor for the Card class has this header:

    Save this class file to the folder where you are creating your Java file:   Card.class

    Ans:

 

Writing to a File

 

Command Line Arguments

 

An Object that Contains an Array