Java

TOPIC 43 – TEST 5 REVIEW

 

 

DETAILS & REVIEW

 

 

DETAILS

 

The test covers Unit 5.  All notes.  All work.  All class discussion is fair game.

Your test will be fully written.  You will not have a computer.

 

Minor programming errors will not count against you.

 

The Java template will not necessarily be provided for you.  You are now expected to know the prototype for the main function.

 

 

REVIEW

 

QUESTION 1

 

Make sure you understand the following terms.

 

Data field

Instance variable
Constructor

Overloading constructors

Default constructor
Instance method

Return-type
Argument list or Parameter list

toString method

Method header (method prototype)

Aggregation
Data encapsulation
public vs private

Set method

Get method

Null

 

QUESTION 2

 

Go through all of the Short Answer Questions in Java OOP Exercises I.


QUESTION 3 – CLASS DESIGN

Consider the class called HealthAppointment that would be used in a software that helps doctors and governments track health services.  What data fields do you think would below to a HealthAppointment object that represents a visit to a family doctor?  List at least five.

QUESTION 4 – PROGRAMMING CONSTRUCTORS


Consider the class below and add the following constructors:

a) a constructor that gets a value for each of the data fields,

b) a constructor that gets no arguments and creates a Point object at (0,0).

     public class Point
     {
         public double x;
         public double y:
     }

QUESTION 5 – PROGRAMMING INSTANCE METHODS

Consider the class below and add an instance method called area() that simply returns the area of the Rectangle object.

 

public class Rectangle

{

    public double width;

    public double height;

 

    public Rectangle(double w, double h)
    {

        width = w;

        height = h;

    }

}

 

QUESTION 6 – PROGRAMMING DATA ENCASULATION

Do the Spaceship class from the Java OOP Exercises.

 

POSSIBLE ADDITIONS

  • NEED AGGREGATION
  • NEED TESTING OF OBJECTS
  • NEED CODE ANALYSIS


 

Good luck!  Stay "classy" Lockerby!

 

 

J