CHAPTER 8 SAMPLE EXAM QUESTIONS 1. Suppose we have 2 classes as described below: A parent...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
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. 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.
Expert Answer:
Answer rating: 100% (QA)
java XYPoint class provided class XYPoint private double x private double y Default constructor public XYPoint thisx 0 thisy 0 Constructor with suppli... View the full answer
Related Book For
Systems analysis and design
ISBN: 978-0136089162
8th Edition
Authors: kenneth e. kendall, julie e. kendall
Posted Date:
Students also viewed these programming questions
-
a.Explain different types of riba with examples. b. The Quran clearly encourages Muslims to provide Qard or benevolent loans, to "those who need them". Critically discuss the reason why Islam permit...
-
This assignment reviews object-oriented programming concepts such as classes, methods, constructors, accessor methods, and access modifiers. It makes use of an array of objects as a class data...
-
Managing Scope Changes Case Study Scope changes on a project can occur regardless of how well the project is planned or executed. Scope changes can be the result of something that was omitted during...
-
Why do investors tend to sell losing stocks together, on the same trading session, and separate the sale of winning stocks over several trading sessions?
-
Gold creek mining company has two competing proposals: a processing mill and an electric shovel. both pieces of equipment have an initial investment of $840,000. The net cash flows estimated for the...
-
Determine the phase of water at a. T = 260C, P = 5 MPa b. T =2C, P = 100 kPa
-
Memorial Medical Center bought equipment on January 2, 2010, for $30,000. The equipment was expected to remain in service for four years and to perform 1,000 operations. At the end of the equipments...
-
BPO Services is in the business of digitizing information from forms that are filled out by hand. In 2006, a big client gave BPO a distribution of the forms that it digitized in house last year, and...
-
TU Limited is in an industry sector which is recovering from the recent recession. The of capacity although directors of the company hope next year to be operating at 85% currently the company is...
-
According to a Bureau of Labor Statistics release of March 25, 2015, statisticians earn an average of $84,010 a year. Suppose that the current annual earnings of all statisticians have the mean and...
-
A cheetah can run at a maximum speed 92.8 km/h and a gazelle can run at a maximum speed of 76.2 km/h. If both animals are running at full speed, with the gazelle 65.8 m ahead, how long before the...
-
What is the key provisions of the pension protection act of 2006 in America and UK ?
-
Dymac Appliances uses the periodic inventory system. Details regarding the inventory of appliances at January 1, purchases invoices during the next 12 months, and the inventory count at December 31...
-
What is cultural exploration and how does it affect hotels and restaurants ?
-
Explain the importance of performance management and why the organizations values performance management. Suggest a performance management system then Explain how to use it in an appropriate way....
-
Logan has a loan that he has to pay $80,000 at the end of the year for 10 years. If Logan wants to pay this loan in monthly terms instead of annual terms and money is worth 15% compounded annually......
-
Erica's Exotics and Aquatics Shoppe is considering investing $540,000 in a project. The project is expected to generate a cash inflow of $90,000 in the first year, $180,000 in the second year,...
-
United Business Forms capital structure is as follows: Debt ............................................ 35% Preferred stock ........................... 15 Common equity .......................... 50...
-
When are open-ended questions appropriate for use in interviewing?
-
What are four actions that can be taken to ensure that the questionnaire format is conducive to a good response rate?
-
What does a process represent on a context-level data flow diagram?
-
Creative Traders Ltd. (CTL) is a Canadian company that conducts business in several countries, using a variety of currencies. The notes to the financial statements pertaining to fair values of...
-
Classification: Elkridge Corporation issued the following financial instruments in \(20 X 4\) : 1. Convertible debentures issued at 103 . The debentures require interest to be paid semiannually at a...
-
Omni Services Ltd., a Canadian public company, is a conglomerate involved in publication of newspapers, media services, and information technology consulting. It recently entered into an agreement to...
Study smarter with the SolutionInn App