• ¿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 45 páginas
Examen

CSE 110 Exam 2 - chapter 5 || Guaranteed Pass.

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

CSE 110 Exam 2 - chapter 5 || Guaranteed Pass.

Vista previa del contenido

CSE 110 Exam 2 - chapter 5 || Guaranteed Pass.
What process helps with identifying the methods that make up a computer program? correct
answers Stepwise refinement


The term "Black Box" is used with methods because correct answers Only the specification
matters; the implementation is not important.


One advantage of designing methods as black boxes is: correct answers Many programmers can
work on the same project without knowing the internal implementation details of methods


After the keywords "public static", what are the names (in order) of the parts of this method
header?
public static int myFun (double a) correct answers Return type, method name, parameter variable
type, parameter variable type


Parameter variables should not be changed within the body of a method because? correct
answers It is confusing because it mixes the concept of a parameter with that of a variable.


What is the output of the following java program?


public class test01{
public static void main(String[] args){
for (int i = 0; i < 4; i++) { System.out.println(myFun(i) + " "); }
}
public static int myFun(int perfect) {
return ((perfect - 1) * (perfect - 1)); }
} correct answers 1 0 1 4


Which option represents a legal invocation of the method square?
public static String square(int a){

,return ("Commencing");
} correct answers String a = square(4);


What statement about the steps for implementing a method is true?


a) Pseudocode is the first step in the process for implementing a method
b) Pseudocode is the last step in the process for implementing a method
c) Unit testing (testing in isolation) of the implemented method is an important first step
d) Unit testing (testing in isolation) of the implemented method is an important final step correct
answers d


What is the problem with the code below?


public static String val() {
String result = "candy";
return;
}
...
// Using method val()System.out.println("The value is: " + val()); correct answers The method
val does not have a return value


What is the problem with the code snippet below?


public class test02{
public static void main(String[] args)
{
System.out.println(cost(10, 4));
}

,public static void cost(int price, int reps)
{
for (int i = 0; i < reps; i++)
{
System.out.print(price);
}
return;
}
} correct answers The method cost returns void and cannot be used as an expression in a print
statement


If a method is declared to return void, then which statement below is true?


a) The method cannot return until reaching the end of the method body
b) The method needs a return statement that always returns the integer value zero
c) When the method terminates no value will be returned
d) The method cannot be invoked unless it is in an assignment statement correct answers c


What is the purpose of a method that returns void? correct answers To package a repeated task as
a method even though the task does not yield a value


What is stepwise refinement? correct answers The process of breaking complex problems down
into smaller, manageable steps


Why is hand-tracing, or manually walking through the execution of a method, helpful? correct
answers It is an effective way to understand a method's subtle aspects


When hand-tracing methods, the values for the parameter variables correct answers Are
determined by the arguments supplied in the code that invokes the method

, A stub method is: correct answers A method that acts as a placeholder and returns a simple value
so another method can be tested


The variable name perfect in the method myFun in the code snippet below is used as both a
parameter variable and a variable in a nested block within the method. Which statement about
this situation is true?


public static int myFun(int perfect)
{
{
int perfect = 0;
return ((perfect - 1) * (perfect - 1));
}
} correct answers This multiple declaration of the variable perfect will not compile because the
scopes overlap


What is the output of the following java program?


public class test03
{
public static void main(String[] args)
{
for (int i = 0; i < 4; i++)
{
System.out.print(myFun(i) + "");
}
System.out.println(); }
public static int myFun(int perfect)
{

Información del documento

Subido en
6 de abril de 2026
Número de páginas
45
Escrito en
2025/2026
Tipo
Examen
Contiene
Preguntas y respuestas
$16.69

¿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.
SirAnton
3.7
(118)
Vendido
807
Seguidores
438
Artículos
40070
Última venta
2 semanas 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