• ¿Documento equivocado? Cámbialo gratis
  • Escrito por estudiantes que aprobaron
  • Inmediatamente disponible después del pago
  • Leer en línea o como PDF
Vender
¿Dónde estudias?
Tu idioma
Document preview thumbnail
Vista previa 2 fuera de 9 páginas
Examen

CMSC 131 Object Oriented Programming I Unit Test 3 - Questions with Correct Answers (Verified Update)

Document preview thumbnail
Vista previa 2 fuera de 9 páginas

CMSC 131 Object Oriented Programming I Unit Test 3 (University of Maryland): 17 exam questions with verified correct answers and rationales, for CMSC 131 at University of Maryland. 9 pages, 2026 verified update. Sample questions covered: Matching case 2 prints something and then case 3's statements also execute without a break. Which concept best describes this situation? | What operation creates another way to access the same object without constructing a distinct object? | Box a = new Box(4); Box b = new Box(a); (6); The final expression is (). Box(Box other) copies the other object’s int field. set writes and | Box a = new Box(10); Box b = new Box(13); (15); The final expression is (). Box stores its constructor argument in an instance field, and se

Vista previa del contenido

CMSC 131 Object-Oriented Programming I: Unit Test 3
Questions and Answers - University of Maryland

1. Matching case 2 prints something and then case 3's statements also execute without a break.
Which concept best describes this situation?
A. Switch fall-through
B. Ternary operator
C. Privacy leak on input
D. Privacy leak on return
Answer: A. Switch fall-through
Rationale: In a traditional colon-style switch, execution can continue into following cases unless it is
redirected.


2. What operation creates another way to access the same object without constructing a distinct
object?
A. continue;
B. break;
C. Reference assignment
D. ready ? max : min
Answer: C. Reference assignment
Rationale: Assigning one reference to another copies the reference and ordinarily keeps the same
original object.


3. Box a = new Box(4); Box b = new Box(a); a.set(6); The final expression is b.get(). Box(Box other)
copies the other object’s int field. set writes and get reads that field. What is returned?
A. 4
B. 6
C. 0
D. 8
Answer: A. 4
Rationale: The separate copy stores the original primitive value, independent of the later source edit.

,4. Which pair of examples illustrates privacy leak on input followed by break statement?
A. A constructor stores its incoming array then caller code edits that array. / A method rejects an
invalid argument with an IllegalArgumentException object.
B. Matching case 2 prints something and then case 3's statements also execute without a break. /
A search exits its nearest loop immediately after finding a match.
C. A constructor stores its incoming array then caller code edits that array. / A search exits its
nearest loop immediately after finding a match.
D. A search exits its nearest loop immediately after finding a match. / A constructor stores its
incoming array then caller code edits that array.
Answer: C. A constructor stores its incoming array then caller code edits that array. / A search exits
its nearest loop immediately after finding a match.
Rationale: Storing a caller's mutable reference directly can let the caller change object state later. An
unlabeled break exits the nearest enclosing switch or loop.


5. Box a = new Box(10); Box b = new Box(13); a.set(15); The final expression is b.get(). Box stores its
constructor argument in an instance field, and set and get write and read it. What does the
expression return?
A. 13
B. 18
C. 15
D. 10
Answer: A. 13
Rationale: a and b denote different Box objects. Updating a does not change b.


6. Box a = new Box(6); Box b = new Box(6); The final expression is a.equals(b) + ":" + (a == b).
Box.equals(Object) compares the stored int values of two boxes. What is the result?
A. true:true
B. false:false
C. false:true
D. true:false
Answer: D. true:false
Rationale: equals tests stored values, whereas the two new expressions create separate object
identities.

Información del documento

Subido en
20 de noviembre de 2026
Número de páginas
9
Escrito en
2026/2027
Tipo
Examen
Contiene
Preguntas y respuestas
$8.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.
DrJon
3.8
(161)
Vendido
620
Seguidores
188
Artículos
29629
Última venta
2 días 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