Question: CHAPTER 8 SAMPLE EXAM QUESTIONS 1. Suppose we have 2 classes as described below: A parent class called XYPoint has already been defined (you

CHAPTER 8 SAMPLE EXAM QUESTIONS 1. Suppose we have 2 classes as described below: A parent class called

CHAPTER 8 SAMPLE EXAM QUESTIONS 1. Suppose we have 2 classes as described below: A parent class called XYPoint has already been defined (you don't need to write code to create this class), and contains only the following: two private double variables representing the x and y coordinates of a point in the xy plane two constructors: a default constructor setting the variables to zero; and a constructor that sets the variables to the value supplied by the application a toString() method an equals() method a set() method - to change the x and y variables to new values Write the code for a Circle class derived from the XYPoint class. The Circle class describes a circle located in the xy plane (to describe a circle you need its centre (a point in the xy plane) and its radius). The Circle class will create/define/redefine only the following (in addition to whatever it inherits from the XYPoint class); a double variable representing the radius of the circle two constructors: a default constructor setting the centre to (0,0) and the radius to 1; and a constructor that sets the centre and radius to values supplied by the client a toString() method an equals() method a set() method to change all the information about the circle To avoid code duplication, use constructors and methods already defined in the XYPoint class whenever possible. 2. For the following methods from the Circle class, from question #1, are they an example of method overloading, method overriding, or neither? Give reasons for your answers. the set() method the toString() method the equals() method 3 Draw a UML diagram that shows the classes involved in question #1 and the relationships between those classes. 4. Write the code that will completely test the Circle class.

Step by Step Solution

3.39 Rating (149 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

java XYPoint class provided class XYPoint private double x private double y Default constructor publ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!