Exam 16: Recursion
Exam 1: Introduction to Computers and Java51 Questions
Exam 2: Java Fundamentals61 Questions
Exam 3: Decision Structures64 Questions
Exam 4: Loops and Files57 Questions
Exam 5: Methods60 Questions
Exam 6: A First Look at Classes58 Questions
Exam 7: Arrays and the Arraylist Class64 Questions
Exam 8: A Second Look at Classes and Objects50 Questions
Exam 9: Text Processing and More About Wrapper Classes60 Questions
Exam 10: Inheritance70 Questions
Exam 11: Exceptions and Advanced File IO56 Questions
Exam 12: A First Look at GUI Applications60 Questions
Exam 13: Advanced GUI Applications58 Questions
Exam 14: Applets and More54 Questions
Exam 15: Creating GUI Applications With Javafx and Scene Builder40 Questions
Exam 16: Recursion42 Questions
Exam 17: Databases48 Questions
Select questions type
Look at the following method: public static int Test2(int x, int y)
{
If ( x < y)
{
Return -5;
}
Else
{
Return (Test2(x - y, y + 5) + 6);
}
}
What is the base case for the method?
(Multiple Choice)
4.8/5
(34)
Look at the following pseudocode algorithm: algorithm Test14(int x)
If (x < 8)
Return (2 * x)
Else
Return (3 * Test14(x - 8) + 8)
End Test14
What value is returned for Test14(7)?
(Multiple Choice)
4.8/5
(32)
Look at the following method: public static int test2(int x, int y)
{
If ( x < y)
{
Return -5;
}
Else
{
Return (test2(x - y, y + 5) + 6);
}
}
What is returned for test2(10, 20)?
(Multiple Choice)
4.9/5
(34)
Recursive algorithms are usually less efficient than iterative algorithms.
(True/False)
4.9/5
(44)
How many times will the following method call itself if the value 10 is passed as an argument?
Public static void message(int n)
{
If (n > 0)
{
System.out.println("Print this line.\n");
Message(n + 1);
}
}
(Multiple Choice)
4.8/5
(41)
To solve a program recursively, you need to identify at least one case in which the problem can be solved without recursion - this is known as the:
(Multiple Choice)
4.7/5
(32)
Look at the following pseudocode algorithm: algorithm Test14(int x)
If (x < 8)
Return (2 * x)
Else
Return (3 * Test14(x - 8) + 8)
End Test14
What value is returned for Test14(16)?
(Multiple Choice)
4.8/5
(40)
The actions that the JVM must perform any time a method is called are known as:
(Multiple Choice)
5.0/5
(34)
Look at the following method: public static int test2(int x, int y)
{
If ( x < y)
{
Return -5;
}
Else
{
Return (test2(x - y, y + 5) + 6);
}
}
What is the recursive case for the method?
(Multiple Choice)
4.8/5
(34)
Which of the following problems can be programmed recursively?
(Multiple Choice)
4.8/5
(36)
If method A calls method B, which in turn calls method A, it is called indirect recursion.
(True/False)
4.8/5
(36)
Indirect recursion occurs when a method calls another method that in turn calls the first method.
(True/False)
5.0/5
(36)
A problem can be solved recursively if it can be broken down into successive smaller problems that are identical to the overall problem.
(True/False)
4.9/5
(43)
Usually, a problem is reduced by making the value of one or more parameters ________ with each recursive call.
(Multiple Choice)
4.7/5
(36)
Showing 21 - 40 of 42
Filters
- Essay(0)
- Multiple Choice(0)
- Short Answer(0)
- True False(0)
- Matching(0)