8.4 Quiz Instructions

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

Today you will continue to enhance your Name class from yesterday's quiz by completing the encasulation of the class data.

Yesterday, one of the things you did was make the Name class fields private which protected and hid them. This is good because users of this class can no longer change the parts of the name encapsulated within the class. The side-effect is users of this class can no longer even see the individual parts of the name.

Add accessor methods to your Name class to allow users of the class to be able to see but not modify the name parts. Name these accessor methods getFirstName, getLastName, and getMiddleInitial.

Your main program will create 1 instance of the Name class, then print the following. The name part lines start with a tab.

  • The full name using the implicit toString method...please note you should NOT explicitly call the toString method.
  • The first name on a line by itself.
  • The middle initial on a line by itself.
  • The last name on a line by itself.

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

Your program must EXACTLY match the designated output found in ClassEncapsulationQuizOutput.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! :)