8.3 Quiz Instructions

You have at most 20 minutes to complete this quiz. It MUST be completed in class.

Today you will enhance your Name class from yesterday's quiz in two steps:

  1. First make its fields private. They should look like this:
    • private String firstName;
    • private String lastName;
    • private String middleInitial;
  2. Second, create two constructors for the Name class:
    1. The first constructor will take no parameters and initialize the class fields to empty strings. This will be the replacement for the default constructor provided by the compiler.
    2. The second constructor will take 3 string parameters, the first name, the middle initial, and the last name (in that order). It will use the parameter values to initialize the appropriate field.

In your main program class, you will create two instances of your Name class:

  1. The first will be named name1 and will use the new default constructor.
  2. The second will be named name2 and will use the 2nd constructor passing in the following name component strings: "John", "Q", "Public".

Your main program will create the 2 instances of the Name class, then print both using the implicit toString method...please note you should NOT explicitly call the toString method.

Name your new main program class <your name>_ClassConstructorQuiz.java.

Your program must EXACTLY match the designated output found in ClassConstructorQuizOutput.txt. Make sure you use the output comparision tool!

You will be submitting two files: one for the Name class and the second for the test program. The Name class will be a non-static (instance) class, whereas your test program class will contain the normal "public static void main" method.

Submit both source code files to me as usual via DropItToMe

Follow class programming standards and formatting/indentation rules. Make sure you comment your code!

Quiz Grading

The quiz is worth 35 points.

This is pretty simple...you get 100% if your output exactly matches the expected output...and...0% if it has ANY differences.

Make sure you get all the spelling, capitalization, punctuation, spacing, etc. correct! Hint: copy-n-paste is a wonderful thing! :)