CS 302 Chapter 9 Exam Questions and
Answers Graded A+
Object - Correct answer-represents an entity in the real world that can be distinctly
identified.
An object is an instance of a class.
Pg. 322
Object creation - Correct answer-The syntax for creating an object:
classname objectReferenceVariable = new classname(arguments if any);
Ex: TV tv1 = new TV(arguments if any)
Pg. 328
Data fields - Correct answer-the state of the object (also known as its properties or
attributes) is represented by data fields with their current values
java uses variables to define data fields
Ex: A circle object has a data field radius which is the property that characterizes
the circle
©COPYRIGHT 2025, ALL RIGHTS RESERVED 1
,Ex: a rectangle object has the data fields width and height which are the properties
that characterize a rectangle
Pg. 323
Behavior of an object - Correct answer-The behavior of an object (also known as
its actions) is defined by methods. To invoke a method on an object is to ask the
object to perform an action
Ex: you may define methods named getArea() and getPerimeter() for circle
objects. A circle object may invoke getArea() to return its area and getPerimeter t0
to return its perimeter
Pg. 323
Class - Correct answer-Objects of the same type are defined using a common class
A class is a template, blueprint or contract the defines what an objects data fields or
methods will be.
A class provides constructors for creating objects and methods for manipulating
them
An object is an Instance of a class. You can create many instances of a class
creating an instance is referred to as INSTANTIATION
A class is also a data type, you can use it to declare reference variables.
©COPYRIGHT 2025, ALL RIGHTS RESERVED 2
,Note: object and instance are used interchangeably
Pg. 323
Constructors - Correct answer-Constructors are special methods that are called
when an object is instantiated. A constructor initializes the created instance.
Typically the constructor initializes the fields of the object that need initialization.
They can perform any action, but constructors are designed to perform initializing
actions, such as initializing the data fields of objects.
Say there were 2 constructors:
Circle(){ //No-arg constructor
radius = 1; //data field radius is initalized to 1
}
Circle(int newRadius){ // argument of type int called newRadius
radius = newRadius; // datafield radius is initalized
}
So if an object was created, the term "new" with no arguments it would invoke the
constructor with the same type of arguments (in this case the constructor with no
arguments)
©COPYRIGHT 2025, ALL RIGHTS RESERVED 3
, So if an object was created with arguments of type int, Ex: Circle myCircle = new
Circle(25), the term "new" would invoke the constructor with the same arguments
(in this case the second constructor with the arguments of type int
Pg 323
UML - Correct answer-Unified modeling language. Class templates and objects
can be illustrated using this UML.
Pg. 323
Data Field syntax - Correct answer-Uses UML
Syntax:
dataFieldname: dataFieldType
Ex: double radius = 1;
Pg. 323
Constructor Syntax - Correct answer-Uses UML
Syntax:
ClassName(parameter name: parameterType)
Ex: Circle(double newRadius) {
}
©COPYRIGHT 2025, ALL RIGHTS RESERVED 4
Answers Graded A+
Object - Correct answer-represents an entity in the real world that can be distinctly
identified.
An object is an instance of a class.
Pg. 322
Object creation - Correct answer-The syntax for creating an object:
classname objectReferenceVariable = new classname(arguments if any);
Ex: TV tv1 = new TV(arguments if any)
Pg. 328
Data fields - Correct answer-the state of the object (also known as its properties or
attributes) is represented by data fields with their current values
java uses variables to define data fields
Ex: A circle object has a data field radius which is the property that characterizes
the circle
©COPYRIGHT 2025, ALL RIGHTS RESERVED 1
,Ex: a rectangle object has the data fields width and height which are the properties
that characterize a rectangle
Pg. 323
Behavior of an object - Correct answer-The behavior of an object (also known as
its actions) is defined by methods. To invoke a method on an object is to ask the
object to perform an action
Ex: you may define methods named getArea() and getPerimeter() for circle
objects. A circle object may invoke getArea() to return its area and getPerimeter t0
to return its perimeter
Pg. 323
Class - Correct answer-Objects of the same type are defined using a common class
A class is a template, blueprint or contract the defines what an objects data fields or
methods will be.
A class provides constructors for creating objects and methods for manipulating
them
An object is an Instance of a class. You can create many instances of a class
creating an instance is referred to as INSTANTIATION
A class is also a data type, you can use it to declare reference variables.
©COPYRIGHT 2025, ALL RIGHTS RESERVED 2
,Note: object and instance are used interchangeably
Pg. 323
Constructors - Correct answer-Constructors are special methods that are called
when an object is instantiated. A constructor initializes the created instance.
Typically the constructor initializes the fields of the object that need initialization.
They can perform any action, but constructors are designed to perform initializing
actions, such as initializing the data fields of objects.
Say there were 2 constructors:
Circle(){ //No-arg constructor
radius = 1; //data field radius is initalized to 1
}
Circle(int newRadius){ // argument of type int called newRadius
radius = newRadius; // datafield radius is initalized
}
So if an object was created, the term "new" with no arguments it would invoke the
constructor with the same type of arguments (in this case the constructor with no
arguments)
©COPYRIGHT 2025, ALL RIGHTS RESERVED 3
, So if an object was created with arguments of type int, Ex: Circle myCircle = new
Circle(25), the term "new" would invoke the constructor with the same arguments
(in this case the second constructor with the arguments of type int
Pg 323
UML - Correct answer-Unified modeling language. Class templates and objects
can be illustrated using this UML.
Pg. 323
Data Field syntax - Correct answer-Uses UML
Syntax:
dataFieldname: dataFieldType
Ex: double radius = 1;
Pg. 323
Constructor Syntax - Correct answer-Uses UML
Syntax:
ClassName(parameter name: parameterType)
Ex: Circle(double newRadius) {
}
©COPYRIGHT 2025, ALL RIGHTS RESERVED 4