Chapter 4 - Writing Classes Flashcards

1
Q

What are the objectives for this chapter?

A
  • 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.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is the heart of object-oriented programming?

A

How come I write my own classes to define my own objects? I design and implement my own classes to suit our specific needs.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is the basic relationship between an object and a class?

A

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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How is the STATE and BEHAVIOR of an OBJECT defined?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

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?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

In Java how are the object’s OPERATIONS defined?

A

In Java the operations of an object are defined by THE METHODS DECLARED in its class.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

WHO determines what attributes and operations are needed? (page 150 - start of 4.2)

A

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)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Collectively, what are the data and methods of a class called?

A

The data and methods of a class are called MEMBERS of a class.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is the heart of object-oriented programming?

A

It is writing/defining classes that represent objects with well-defined state and behavior.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly