CS335
Fall, 2008
Homework 2 (20 points)
Due: 9/16/08 (Tuesday)

**********************************************************************

1.  The "main" method of a class has always to be a "static" method.
    Why? What would happen if you define the "main" method as a
    non-static method? (4 points)


2.  (a) What is a "constructor"? Constructors can be overloaded.
        Why do you think it is necessary to have overloaded
        constructors? give me at least one reason. (2 points)

    (b) A constructor can not have return type or return value.
        Why? (2 points)
    

3.  A user outside an object can accessed/mutated a private instance
    variable through its public methods. Does this mean there is no
    need to have private instance variables in a class? Why?
    (4 points)


4.  Write a Java program to perform the following task:

    The program maintains six digits on the same line of the
    screen, separated by space.
    Each digit is set to zero initially.
    If the user pushes the number i (1 <= i <= 6) key of the keyboard,
    the program changes the i-th digit by adding 1 to that digit.
    The digit 9 should change to 0.  When the six digits are set to
    display the digit sequence ``281562'', print out the message "Hey,
    Dude, welcome to Java club."  All other combinations should print
    the message "xxxxxx is not the right sequence", where "xxxxxx" is
    the current digit sequence. (8 points)



************************************************************************


Put you solution set in a text file with the following header and
email me that text file before midnight of the due day.

           CS335 (Fall 2008)
           Solution of Homework 2
           Due: 9/16/08
		   Name: xxxxxx xxxxxx

The answer to Problem 4 should be the exact content of
a .java file so we can easily edit it and test it.