Escrito por estudiantes que aprobaron Inmediatamente disponible después del pago Leer en línea o como PDF ¿Documento equivocado? Cámbialo gratis 4,6 TrustPilot
logo-home
Document preview thumbnail
Vista previa 4 fuera de 37 páginas
Examen

CS 302 Chapter 9 Exam Questions and Answers Graded A+

Document preview thumbnail
Vista previa 4 fuera de 37 páginas

CS 302 Chapter 9 Exam Questions and Answers Graded A+

Vista previa del contenido

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

Información del documento

Subido en
31 de enero de 2026
Número de páginas
37
Escrito en
2025/2026
Tipo
Examen
Contiene
Preguntas y respuestas
$12.99

¿Documento equivocado? Cámbialo gratis Dentro de los 14 días posteriores a la compra y antes de descargarlo, puedes elegir otro documento. Puedes gastar el importe de nuevo.
Escrito por estudiantes que aprobaron
Inmediatamente disponible después del pago
Leer en línea o como PDF

Seller avatar
Los indicadores de reputación están sujetos a la cantidad de artículos vendidos por una tarifa y las reseñas que ha recibido por esos documentos. Hay tres niveles: Bronce, Plata y Oro. Cuanto mayor reputación, más podrás confiar en la calidad del trabajo del vendedor.
EmillyCharlotte
3.5
(31)
Vendido
139
Seguidores
5
Artículos
12431
Última venta
1 semana hace


Por qué los estudiantes eligen Stuvia

Creado por compañeros estudiantes, verificado por reseñas

Calidad en la que puedes confiar: escrito por estudiantes que aprobaron y evaluado por otros que han usado estos resúmenes.

¿No estás satisfecho? Elige otro documento

¡No te preocupes! Puedes elegir directamente otro documento que se ajuste mejor a lo que buscas.

Paga como quieras, empieza a estudiar al instante

Sin suscripción, sin compromisos. Paga como estés acostumbrado con tarjeta de crédito y descarga tu documento PDF inmediatamente.

Student with book image

“Comprado, descargado y aprobado. Así de fácil puede ser.”

Alisha Student

Preguntas frecuentes