• ¿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 6 - 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 6 (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: What can happen if a nonnull object cannot be treated as the requested subtype? | int n = 7; The final expression is stepCount(n). Given static int stepCount(int n) { return n = 0 ? 0 : 1 + stepCount(n - 2); }, what is returned? | What makes a method call recursive in the direct form? | Which statement best characterizes Javadoc return tag?

Vista previa del contenido

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

1. What can happen if a nonnull object cannot be treated as the requested subtype?
A. super(...)
B. A ClassCastException
C. Inheritance using extends
D. Composition
Answer: B. A ClassCastException
Rationale: A checked reference cast can fail if the referenced object is not an instance of the
requested type.


2. int n = 7; The final expression is stepCount(n). Given static int stepCount(int n) { return n <= 0 ? 0 : 1
+ stepCount(n - 2); }, what is returned?
A. 9
B. 7
C. 4
D. 3
Answer: C. 4
Rationale: Every positive invocation contributes one and recurs with n smaller by two.


3. What makes a method call recursive in the direct form?
A. After that recursive call returns
B. Method overriding
C. StackOverflowError
D. The method calls itself
Answer: D. The method calls itself
Rationale: A recursive call invokes the same method directly or through another recursive path.

,4. A team compares iterator with interface extension. Which examples fit in the same order?
A. A program requests successive values through hasNext and next. / A new interface adds a
method to an existing smaller interface contract.
B. The file imports java.util.Scanner and can then use Scanner in a declaration. / A new interface
adds a method to an existing smaller interface contract.
C. A new interface adds a method to an existing smaller interface contract. / A program requests
successive values through hasNext and next.
D. A program requests successive values through hasNext and next. / A method's comment
explains the meaning of its input count.
Answer: A. A program requests successive values through hasNext and next. / A new interface adds a
method to an existing smaller interface contract.
Rationale: An iterator provides sequential traversal of a collection through a cursor-like object. One
interface can use extends to include and build on other interface contracts.


5. Which statement best characterizes Javadoc return tag?
A. An import can make a type available by its simple name, subject to naming rules.
B. Step into follows execution into a method call where source is available.
C. hasNext reports whether a following element is available without returning it.
D. A Javadoc @return tag describes the meaning of a returned result.
Answer: D. A Javadoc @return tag describes the meaning of a returned result.
Rationale: A Javadoc @return tag describes the meaning of a returned result. Consider this example.
An API comment explains when a search method returns its failure sentinel.


6. What command should be used to follow control into a helper method?
A. Step into
B. Use @param with the parameter's name and meaning
C. A Javadoc documentation comment
D. Step over
Answer: A. Step into
Rationale: Step into follows execution into a method call where source is available.

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