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

CMSC 131 Object Oriented Programming I Case Studies - Questions with Correct Answers (Verified Update)

Document preview thumbnail
Vista previa 3 fuera de 17 páginas

CMSC 131 Object Oriented Programming I Case Studies (University of Maryland): 34 exam questions with verified correct answers and rationales, for CMSC 131 at University of Maryland. 17 pages, 2026 verified update. Sample questions covered: A campus event calculator reads a whole number of tickets and a one-word zone from Scanner in. All numeric variables are int unless stated otherwise. | A campus event calculator reads a whole number of tickets and a one-word zone from Scanner in. All numeric variables are int unless stated otherwise. | A campus event calculator reads a whole number of tickets and a one-word zone from Scanner in. All numeric variables are int unless stated otherwise. | A campus event calculator reads a whole number of tickets and a one-word zone from Scanner in. All numeric variables are int unless stated otherwise.

Vista previa del contenido

CMSC 131 Object-Oriented Programming I: Case Studies
Questions and Answers - University of Maryland

1. A campus event calculator reads a whole number of tickets and a one-word zone from Scanner in.
All numeric variables are int unless stated otherwise. A regular ticket costs nine dollars. The entry "7
north" is valid input. What should read the ticket count as an int?
A. in.nextInt()
B. in.hasNext()
C. System.out.print(in)
D. in.nextLine()
Answer: A. in.nextInt()
Rationale: nextInt converts the next valid token to an int.


2. A campus event calculator reads a whole number of tickets and a one-word zone from Scanner in.
All numeric variables are int unless stated otherwise. A regular ticket costs nine dollars. The entry "7
north" is valid input. After reading the count with nextInt(), what does in.next() return?
A. 7
B. north
C. An empty string
D. 7 north
Answer: B. north
Rationale: The integer token was consumed. next reads the following token under the default
delimiter.


3. A campus event calculator reads a whole number of tickets and a one-word zone from Scanner in.
All numeric variables are int unless stated otherwise. A regular ticket costs nine dollars. The entry "7
north" is valid input. For int count = 7, what is count * 9?
A. 63
B. 72
C. 79
D. 16
Answer: A. 63
Rationale: Seven tickets at nine dollars each cost 63 dollars.

,4. A campus event calculator reads a whole number of tickets and a one-word zone from Scanner in.
All numeric variables are int unless stated otherwise. A regular ticket costs nine dollars. The entry "7
north" is valid input. If seven tickets are divided into groups of three using int division, what are
quotient and remainder?
A. 3 and 1
B. 2 and 0
C. 1 and 2
D. 2 and 1
Answer: D. 2 and 1
Rationale: Seven divided by three yields quotient two with one ticket left.


5. A campus event calculator reads a whole number of tickets and a one-word zone from Scanner in.
All numeric variables are int unless stated otherwise. A regular ticket costs nine dollars. The entry "7
north" is valid input. Which check requires at least one ticket and allows at most ten?
A. count <= 10
B. count > 1 && count < 10
C. count >= 1 && count <= 10
D. count == 1 && count == 10
Answer: C. count >= 1 && count <= 10
Rationale: Both inclusive bounds must hold at the same time.


6. A fee calculator uses ordered if branches. A late return with more than five days costs 12 dollars. A
late return with one to five days costs four dollars. A non-late item has cost zero. Why should a
condition for more than five days precede a broader condition for positive days in an else-if chain?
A. The later true branch always overrides an earlier true branch
B. Java always reorders conditions from most specific to least specific
C. Positive day counts cannot be compared with a literal
D. Otherwise the broader true condition would take the branch that also covers more than five
days
Answer: D. Otherwise the broader true condition would take the branch that also covers more than
five days
Rationale: An else-if chain chooses the first true branch, so order matters when conditions overlap.

,7. A fee calculator uses ordered if branches. A late return with more than five days costs 12 dollars. A
late return with one to five days costs four dollars. A non-late item has cost zero. What is the fee if
lateDays is exactly five?
A. 0 dollars
B. 12 dollars
C. 5 dollars
D. 4 dollars
Answer: D. 4 dollars
Rationale: Five is at the inclusive top end of the lower late-fee bucket.


8. A fee calculator uses ordered if branches. A late return with more than five days costs 12 dollars. A
late return with one to five days costs four dollars. A non-late item has cost zero. Which structure
permits a program to display both an overdue message and an unrelated member reminder?
A. Two independent if statements when both messages can apply
B. One else-if chain for the two messages
C. A single branch with the two conditions combined solely by negation
D. A do-while loop without any condition check on each message
Answer: A. Two independent if statements when both messages can apply
Rationale: Independent tests can both execute when both are true.


9. A fee calculator uses ordered if branches. A late return with more than five days costs 12 dollars. A
late return with one to five days costs four dollars. A non-late item has cost zero. What happens when
Java evaluates boolean ok = denominator != 0 && 20 / denominator > 1 with denominator equal to 0?
A. Java evaluates the right operand and throws ArithmeticException
B. Short-circuiting prevents the comparison of denominator with zero
C. The right operand is skipped, so there is no division
D. The quotient is rounded before division occurs
Answer: C. The right operand is skipped, so there is no division
Rationale: Conditional AND stops after a false left operand.

Información del documento

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