Quiz 3 & 4

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

The _____ case defined in a function stops recursion. loop terminal base start

base

A stack overflow typically causes a program to _____. give an incorrect output crash return a value give multiple outcomes

crash

What does the command line or terminal allow the user to do? directly interact with the operating system directly interact with the hard drive directly interact with the monitor directly interact with a program

directly interact with the operating system

Identify the base case in the following code. public class FindMatch { public static int findMatch(char array[], int low, int high, char key) { if (high >= low) { int mid = low + (high - low) / 2; if (array[mid] == key) { return mid; } if (array[mid] > key) { return findMatch(array, low, mid, key); } else { return findMatch(array, mid + 1, high, key); } } return -1; } } (high>=low) if (array[mid] == key) int mid = low + (high - low)/2; if (array[mid] > key)

if (array[mid] == key)

Which XXX will lead to stack overflow? public class RecursionExample { public static void reverseCount(int locNum) { XXX { locNum = locNum-1; System.out.println("hello"); reverseCount(locNum); } } public static void main(String[] args) { reverseCount(3); } } if(locNum == 3) if(locNum > 3) if(locNum <= 3) if(locNum > 0)

if(locNum <= 3)

Binary search begins at the ______ of the range. first element midpoint given index last element

midpoint

Which of the following recursive methods will result in a stack overflow when main() calls fact(10)? public static int fact(int n) { if (n != 100) return 1; else return n*fact(n-1); } public static int fact(int n){ if (n <= 100) return 1; else return n*fact(n-1); } public static int fact(int n) { if (n < 100) return 1; else return n*fact(n-1); } public static int fact(int n) { if (n == 100) return 1; else return n*fact(n-1); }

public static int fact(int n) { if (n == 100) return 1; else return n*fact(n-1); }

What is output? public class RecursionExample { public static void printer() { System.out.println("hello"); printer(); } public static void main(String[] args) { printer(); } } hello hello hello hello hello hello stack overflow

stack overflow

A debugger can step through a program when _____________ the programmer sets a break point which pauses the program, and then begins stepping through the program. a system level error occurs that causes an interrupt in the program. an error is detected by the debugger that pauses the program, and then begins stepping through the program one line at a time. the user activates debug mode to check code.

the programmer sets a break point which pauses the program, and then begins stepping through the program.

A break point is set when _________. the programmer wants to pause the program to see what the state of the variables are at that point in the program the programmer wants to display the contents of a variable to the user the programmer wants to end a program that has bad data in its variables a program detects an error in its data.

the programmer wants to pause the program to see what the state of the variables are at that point in the program

When using a centralized VCS, what two things must happen to be able to see your changes in a program? you update, they commit you commit, they update . you commit, they commit you update, they update

you commit, they update .

How many times is numberOfStudents() called if main() calls numberOfStudents(9)? public static void numberOfStudents(int num) { if (num >= 10) { System.out.println(num); } else { System.out.print("Bye"); numberOfStudents(num+1); } } 9 1 10 2

2

What is output for countNum(5);? public class CountNum { public static void countNum(int num) { if (num <= 0) { System.out.println("Done"); } else { System.out.print(num + " "); countNum(num - 2); } } } 5 3 1 -1 Done 5 3 1 Done 5 4 3 2 1 Done 5 3 1 0 Done

5 3 1 Done

Which is true? Passing all test cases ensures a program is bug free Calling every method once ensures 100% code coverage A testbench should test all possible values A testbench should only print messages when a test case fails

A testbench should only print messages when a test case fails

What is the main function of a Debugging Tool? Allow the programmer to examine how their program is working. Automatically correct errors in a program. Allow a programmer to examine how individual instructions are working. Document errors in a program.

Allow the programmer to examine how their program is working.

Features of a good testbench include: Test cases for all possible values At least 90% code coverage Messages for all tests that pass Border cases and extreme values

Border cases and extreme values

What is output? public class RecursiveFactorial { public static int factorial(int factValue) { if (factValue <= 0) { return 1; } else { return factValue*factorial(factValue-1); } } public static void main (String [] args) { int userVal = -5; System.out.println("Factorial = " + factorial(userVal)); } } Factorial = -120 Error Factorial = 1 Factorial = 120

Factorial = 1

What is a simple method that a programmer can use to identify when a variable does not contain the expected value? Insert print statements to display the value of variables Insert a program exit if a value is incorrect. Insert a user request to change the value of an incorrect variable. Insert print statement to ask the user what the correct value should be

Insert print statements to display the value of variables

Why is having a Version Control system is so Important? It allows software to be fully test by providing version links into the testable units of the software. It allows the merging of code from different programmers working on the same program. It allows other programmers to see what another programmer is currently working on. It is not. Version Control Systems wase valuable programmer time with unnecessary administrative work. It allows multiple programmers to safely work on different programs.

It allows the merging of code from different programmers working on the same program.

What is the primary purpose of Version Control Software? Keep track of who worked on a program. Keep track of bug fixes. Keeps track of multiple versions of a program.

Keeps track of multiple versions of a program.


संबंधित स्टडी सेट्स

Women's Health (Exam Practice questions)

View Set

Khan Academy Ap CompSci Principles Data analysis

View Set

I-core marketing practice questions 1,5,2,6,9,11

View Set

ASNT Level 3 Basic Materials & Processes

View Set

ES - #4 - WATER POLUTION - CHAPTER 11

View Set

Top 5 Hardest Geography questions (for you Anton) NO CHEATING!!!!!!!!!!1

View Set

DMV Questions (NO SIGN PICTURES)

View Set

Modules 1 - 4: Switching Concepts, VLANs, and InterVLAN Routing Exam

View Set