Name: ____________________________________________________ Alpha: _____________________

Describe help received: _________________________________________________________________

  1. [10pts] Suppose you were working on a class Date that represents a date, obviously, and would provide basic functionality for reading dates in various formats, writing dates in various formats, and doing other date-related tasks. You will certainly want an array of the names of the months for both reaing and writing. It gives you an easy way to convert month "1" to month "January". Which of the following is the most appropriate declaration for the field. Explain your answer thoroughly!
    1. public String[] mnames = {"January", "February", "March", "April", "May", "June", 
                                 "July", "August", "Septemnber", "October", "November", "December"};
    2. public static String[] mnames = {"January", "February", "March", "April", "May", "June",
                                        "July", "August", "Septemnber", "October", "November", "December"};
    3. public static final String[] MNAMES = {"January", "February", "March", "April", "May", "June", 
                                              "July", "August", "Septemnber", "October", "November", "December"};
    4. private static String[] mnames = {"January", "February", "March", "April", "May", "June", 
                                         "July", "August", "Septemnber", "October", "November", "December"};
    5. private static String[] mnames = {"January", "February", "March", "April", "May", "June",
                                         "July", "August", "Septemnber", "October", "November", "December"};
    6. private static final String[] mnames = {"January", "February", "March", "April", "May", "June", 
                                               "July", "August", "Septemnber", "October", "November", "December"};
  2.  1: public class Foo {
     2:   private String name;
     3:   public static int n;
     4:   private static final double R = .05;
     5:   public Foo(String name) {
     6:     name = name;
     7:     n = 0;
     8:     R = R + 0.1;
     9:   }
    10:    <other code>
    11: }	  	
    1. What's wrong with line 6 and what should be done to fix it?
    2. What's wrong with lines 3 and 7 and what should be done to fix it?
    3. What's wrong with line 8 and what should be done to fix it?