• Wrong document? Swap it for free
  • Written by students who passed
  • Immediately available after payment
  • Read online or as PDF
Sell
Where do you study
Your language
Document preview thumbnail
Preview 4 out of 45 pages
Exam (elaborations)

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

Document preview thumbnail
Preview 4 out of 45 pages

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

Content preview

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)
{

Document information

Uploaded on
April 6, 2026
Number of pages
45
Written in
2025/2026
Type
Exam (elaborations)
Contains
Questions & answers
$16.69

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
SirAnton
3.7
(118)
Sold
807
Followers
438
Items
40070
Last sold
2 weeks ago




Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their exams and reviewed by others who've used these revision notes.

Didn't get what you expected? Choose another document

No problem! You can straightaway pick a different document that better suits what you're after.

Pay as you like, start learning straight away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and smashed it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions