• ¿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 4 fuera de 35 páginas
Examen

CMSC 131 Object Oriented Programming I Final Exam - Questions with Correct Answers (Verified Update)

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

CMSC 131 Object Oriented Programming I Final Exam (University of Maryland): 66 exam questions with verified correct answers and rationales, for CMSC 131 at University of Maryland. 35 pages, 2026 verified update. Sample questions covered: How is Javadoc comment most accurately defined? | StackInteger s = new Stack(); (6); (8); (); What is the value of ()? | What expression yields the old value of i and also increments i? | Box a = new Box(9); Box b = a; (13); The final expression is (). Box stores an int field initialized by its constructor. Its set and get met

Vista previa del contenido

CMSC 131 Object-Oriented Programming I: Final Exam
Questions and Answers - University of Maryland

1. How is Javadoc comment most accurately defined?
A. A breakpoint pauses a debugger at a selected executable location when reached.
B. An import can make a type available by its simple name, subject to naming rules.
C. Step into follows execution into a method call where source is available.
D. A Javadoc documentation comment can describe API contracts and produce generated
documentation.
Answer: D. A Javadoc documentation comment can describe API contracts and produce generated
documentation.
Rationale: A Javadoc documentation comment can describe API contracts and produce generated
documentation. Consider this example. A public method's documentation is written before its
declaration using /** ... */.


2. Stack<Integer> s = new Stack<>(); s.push(6); s.push(8); s.pop(); What is the value of s.peek()?
A. 10
B. 6
C. 0
D. 8
Answer: B. 6
Rationale: The most recently pushed item was removed, exposing the original item.


3. What expression yields the old value of i and also increments i?
A. Multiplication has higher precedence than addition
B. ++i
C. i++
D. Sum each digit times its corresponding power of two
Answer: C. i++
Rationale: A postfix increment yields the variable's previous value and updates the variable as a side
effect.

,4. int n = 5; boolean ok = n < 5 && ++n > 0; What is the value of n?
A. 4
B. 5
C. 6
D. 7
Answer: B. 5
Rationale: The equality boundary makes the left comparison false. Conditional AND skips the
increment.


5. Box a = new Box(9); Box b = a; b.set(13); The final expression is a.get(). Box stores an int field
initialized by its constructor. Its set and get methods write and read it. What is returned?
A. 10
B. 13
C. 0
D. 9
Answer: B. 13
Rationale: The assignment copies a reference, so both variables denote the instance updated by set.


6. How can code explicitly signal an unsuitable argument through an exception?
A. Throw an IllegalArgumentException
B. break;
C. Control falls through unless a transfer such as break stops it
D. continue;
Answer: A. Throw an IllegalArgumentException
Rationale: A throw statement transfers control by raising a particular exception object.

,7. A part of a string begins at index 2 and ends just before index 5. Which course concept gives the
most specific explanation?
A. String equals
B. Pass by value
C. Substring
D. Character indexing
Answer: C. Substring
Rationale: String.substring with two indices includes the start index and excludes the end index.


8. int[] a = new int[11]; int x = a[11]; What happens when the final statement runs?
A. NumberFormatException
B. ArrayIndexOutOfBoundsException
C. Completes normally
D. NullPointerException
Answer: B. ArrayIndexOutOfBoundsException
Rationale: An array of length n has last valid index n - 1.


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

,10. What property makes the initialized grid rectangular?
A. grid.length
B. Each nonnull row has the same number of cells
C. grid[r].length
D. Row by row
Answer: B. Each nonnull row has the same number of cells
Rationale: A rectangular representation has nonnull rows with the same length.


11. Which observations give valid examples of interface extension and iterator next, respectively?
A. A new interface adds a method to an existing smaller interface contract. / A loop tests eligibility
for another next() call.
B. The file imports java.util.Scanner and can then use Scanner in a declaration. / A traversal
retrieves the next name and moves forward.
C. A new interface adds a method to an existing smaller interface contract. / A traversal retrieves
the next name and moves forward.
D. A traversal retrieves the next name and moves forward. / A new interface adds a method to an
existing smaller interface contract.
Answer: C. A new interface adds a method to an existing smaller interface contract. / A traversal
retrieves the next name and moves forward.
Rationale: One interface can use extends to include and build on other interface contracts. next
returns a further element and advances iteration if an element remains.


12. A class with no written constructors is instantiated with no arguments under appropriate access.
Which concept most directly fits this example?
A. toString
B. Getter
C. Implicit default constructor
D. Instance method
Answer: C. Implicit default constructor
Rationale: Java provides a default constructor when a class declares no constructor.

Información del documento

Subido en
20 de noviembre de 2026
Número de páginas
35
Escrito en
2026/2027
Tipo
Examen
Contiene
Preguntas y respuestas
$13.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