Chapter 4 - Writing Classes Flashcards
What are the objectives for this chapter?
- Discuss the STRUCTURE AND CONTENT of a class definition.
- Establish the concept of object state using instance data.
- Describer the effect of visibility modifiers on methods and data.
- Explore the structure of a method definition, including parameters and return values.
- Discuss the structure and purpose of a CONSTRUCTOR.
- Define and display ARC shapes.
- Load and Display IMAGES.
- Introduce the concepts needed to create an interactive graphical user interface.
- Explore some basic GUI CONTROLS and event processing.
What is the heart of object-oriented programming?
How come I write my own classes to define my own objects? I design and implement my own classes to suit our specific needs.
What is the basic relationship between an object and a class?
A class is a blueprint of an object. Student class is the blueprint and an actual student is an object of that class.
The student CLASS establishes what ATTRIBUTES the student OBJECT has, defined by the VARIABLES in the class (and OPERATIONS).
How is the STATE and BEHAVIOR of an OBJECT defined?
The STATE of the object is defined by the values of the Attributes.
The object also has BEHAVIORS, which are defined by the operations associated with that object.
The behavior of an object may MODIFY the STATE of that object.
What are some examples of attributes (that define the state of an object) AND operations (which define the behaviors of an object) for a Student OBJECT in a Student class?
Some attributes are the name, address, major, and grade point average.
Some operations are the ABILITY to update the address and COMPUTE the grade point average.
The CLASS defines the operations, like how the GPA is calculated.
In Java how are the object’s OPERATIONS defined?
In Java the operations of an object are defined by THE METHODS DECLARED in its class.
WHO determines what attributes and operations are needed? (page 150 - start of 4.2)
The program designer determines what attributes and operations are needed.
What attributes and operations needed depend on the PURPOSE of the program and the ROLE a particular object plays in that purpose. (page 150 - start of 4.2)
Collectively, what are the data and methods of a class called?
The data and methods of a class are called MEMBERS of a class.
What is the heart of object-oriented programming?
It is writing/defining classes that represent objects with well-defined state and behavior.