Practice Coding Questions

  1. Define an abstract class called Shape. Make it mandatory that every
    sub-class has a method void drawShape( ) and String typeOfShape( ). The
    class Shape should have one instance variable (that will be inherited)
    called the_char, of type char. You should also keep track of the number
    of Shape class objects instantiated (use a static counter variable).
    Shape should have a constructor and finalizer.
  2. Define a (non-abstract i.e. concrete) sub-class Square. It should also
    keep track of the number of Square class objects instantiated and have a
    constructor and finalizer. The method void drawShape( ) use the instance
    variable the_char and the method System.out.println to draw a square.
    String typeOfShape( ) should return "Square"
  3. Define a class with a main method. The main method should allow the
    user to enter a name and date of in one JOptionPane in the form
    Smith, Henry born 3/4/1978
    In a JTextArea display the message "Hello Henry Smith" (use the person's name
    in place of Henry Smith) and tell them how many years old they are.
  4. Make your own special array class called ArrayClass. It should have an int array
    reference as an instance variable. It should have
  5. Define a class called Currency. It should keep how many dollars foriegn
    currencies and methods to do conversions of foriegn currencies to us dollars
    and vice-versa. Define the public final instance variables and public methods Why should all these methods and final instance variables be static?