(The Watch as an Object) You are probably wearing on your wrist one of the world’s most common types of objects—a watch. Discuss how each of the following terms and concepts applies to the notion of a watch: object, attributes, behaviors, class, inheritance (consider, for example, an alarm clock), encapsulation, interface, information hiding, data members and member functions.

What will be an ideal response?


The entire watch is an object that is composed of many other objects (such as the moving parts, the band, the face, etc.) Watch attributes are time, color, band, style (digital or analog), etc. The behaviors of the watch include setting the time and getting the time. A watch can be considered a specific type of clock (as can an alarm clock). With that in mind, it is possible that a class called Clock could exist from which other classes such as watch and alarm clock could inherit the basic features of the clock. The watch is an abstraction of the mechanics needed to keep track of the
time. The user of the watch does not need to know the mechanics of the watch in order to use it; the user only needs to know how to read the face of the watch and that the watch keeps the proper time. In this sense, the mechanics of the watch are encapsulated (hidden) inside the watch. The interface to the watch (its face and controls for setting the time) allows the user to set and get the time. The user is not allowed to directly touch the internal mechanics of the watch. All interaction with the internal mechanics is controlled by the interface to the watch. The data members stored in the watch are hidden inside the watch and the member functions (looking at the face to get the time and setting the time) provide the interface to the data.

Computer Science & Information Technology

You might also like to view...

Consider the classes below:

``` public class TestA { public static void main(String args[]) { int x = 2; int y = 20 int counter = 0; for (int j = y % x; j < 100; j += (y / x)) counter++; } } public class TestB { public static void main(String args[]) { int counter = 0; for (int j = 10; j > 0; --j) ++counter; } } ``` Which of the following statements is true? a. The value of counter will be different at the end of each for loop for each class. b. The value of j will be the same for each loop for all iterations c. Both (a) and (b) are true. d. Neither (a) nor (b) is true.

Computer Science & Information Technology

Draw a sequence diagram for the HappyHourMessage scenario in the figure below. Draw only the first five messages exchanged.

What will be an ideal response?

Computer Science & Information Technology

What is the purpose of 'Total' in the MySQL statement CREATE PROCEDURE Total_Orders (OUT Total FLOAT);?

a. parameter b. function c. stored procedure d. trigger

Computer Science & Information Technology

Match the following properties/methodsto their respective descriptions.

A. Returns the number of elements in the form B. Resets the web form C. Submits the web form D. Initiates autocompletion of those form fields that have autocomplete activated E. Allows the browser to automatically complete form fields

Computer Science & Information Technology