WorksheetsCS 241 Practice Test Week 2
Total questions: 61
Worksheet time: 2hrs 44mins
What type of error will this cause, where there should be a semicolon at the end of this Java command?
String name = "Joe
Syntax Error
Lexical
Run-time Error
Logic Error
The Java code segment below has been saved in a file called "JollyMessage.java". What type of error, if any, will occur?
Syntax
Run-time
Logic
Lexical
No Error
Errors that occur during the execution of a program happen in ___________ _________.
run time
compile time
Arranging commands in a programming statement not in the required order is a ______________ error.
syntax
logic
runtime
lexical
In some languages, forgetting to end a statement with a semicolon is a ______________ error.
logic
runtime
syntax
lexical
Syntax errors occur during ___________ _________.
run time
compile time
Logic errors occur during ___________ _________.
run time
compile time
Leaving out a required closing brace, bracket, or parentheses is a ______________ error.
Lexical
Syntax
Runtime
Logic
Lexical errors occur during ___________ _________.
compile time
runtime
What part of the method is highlighted here?
header
method call
body
return type
what part of the method is highlighted here?
header
return type
method name
parameter list
What part of the method is highlighted here?
method name
header
return type
method call
What part of the method is highlighted here?
method end
parameter list
method name
return type
What part of the method is highlighted here?
method name
method parameters
method type
return method
What part of the method is highlighted here?
return type
parameter list
method name
method end
The block of code that makes up the process performed by a procedure, function, or method.
definition/body
parameter list
header
call
A statement that activates or executes a procedure, function, or method.
call
header
parameter list
definition/body
A block of code that performs an action without returning a value.
function
method call
return method
procedure
The first line of a procedure, function, or method.
definition/body
parameter list
header
call
A variable in the parameter list of a method header.
Reference parameter
Value parameter
Formal parameter
Actual parameter
A value, variable, or expression in the parameter list of a method call.
Reference Parameter
Actual Parameter
Value Parameter
Formal Parameter
The type of parameter where changes by the method DO NOT affect the original data.
Formal Parameter
Value Parameter
Actual Parameter
Reference Parameter
In the pseudocode example shown, "Suzy" is an example of a(an) ______________ parameter
Actual
Formal
Value
Reference
A programming block of code that performs a calculation and sends back the result of that calculation.
Function or return method
Definition
Header
Procedure, void method
Call
What is printed by the code segment shown below?
16
22
42
64
48
What is output the code segment shown below?
5*4
20
1
5,4
What is output by the code segment shown below?
48 48
48 12
12 48
12 12
What is output by the code segment shown below?
16 5 16
16 5 5
16 7 16
16 7 7
What is the output by the code segment shown below?
No ouput
x+y
11
5+6
What is output by the code segment shown below?
11
4+7
9+9
18
What is output by the code segment shown below?
2272
2777
2277
7722
What is output by the code segment shown below?
2-2:2:10:10:10-
2-2:2:7:10:10-
2-2:2:7:5:2-
2-2:2:7:10:2-
Consider the following method:
What is returned by the method call sum(7,6)
13
7
Nothing
7+6
Consider the following method. What is is printed by the method call sum(8,10) ?
8+10
2
18
10-8
4
14
9 5
5 9
Consider the following method. What is returned by the method call f(30)?
Large
Small
Nothing is printed
LargeSmall
Consider the following method. What is output by the method call: print greetTheDay(14)
Good day
Good evening
Good monring
nothing
What is output of this code segment?
1
0
17
35
What is printed?
WednesdayThursdayFridaySaturday
Sunday
Tuesday
Saturday
What is printed?
Sunday
Saturday
WednesdayThursdayFridaySaturday
Tuesday
What is printed?
"Poorly done. You can do better!"
"An very good grade!"
"This isn't a grade!"
"Very average."
What is printed?
Mangoes and papayas are $2.79 a pound."
"Bananas are $0.48 a pound."
"Oranges are $0.59 a pound."
"Sorry, we're out of Mangoes"
Which of these reserved words is NOT used to control a switch statement?
case
continue
default
switch
break
The switch statement below should calculate a week's pay based on number of years experience. For 1 year of experience, the hourly wage is $7, for 2 years $8 an hour, 3 years $10, 4 years $12, and 5 years $15 per hour. The number of hours will vary between 1 and 40 hours. Which choice will be used to correctly calculate the totalWeekPay so that the output shown is $200?
case 1: totalWeekPay = hours*7;break;
case 4: totalWeekPay = hours*15;break;
case 3: totalWeekPay = hours*10;break;
case 2: totalWeekPay = hours*8;break;
case 3: totalWeekPay = hours*12;break;
What is printed?
"default"
"Buzz"
"FizzBuzz"
"Fizz"
Which choice represents a program feature that activates a predefined block of code?
Method header
Return method or function
Method Definition
Void Method or procedure
Method call
When a program executes just fine, but the outcome is incorrect, this is a classified as a ______________ error.
logic
runtime
syntax
lexical
Which of the following are considered good program debugging strategies? Check all that apply.
Intentionally use bad data to see if your program can handle it.
Look at the arrows in the compiler generated error messages to locate the error.
Hide portions of the program that don't seem to work and "unhide" them one at a time until the offending line is discovered.
Read the error messages provided by the compiler.
Which choice describes a programming block of code that produces a calculated value?
method header
method definition
return method or function
void method or procedure
method call
In this pseudocode example, String name is an example of a(an) __________ parameter.
Formal
Reference
Actual
Value
Not capitalizing a reserved word that should be capitalized in a programming statement is a ______________ error.
Runtime
Logic
Syntax
Lexical
Which choices represent the possible operators correctly filling the blank resulting in an output value of 14? Check all that apply.
==
≤
=
<
≥
Forgetting to end a string with a double quote symbol is a ______________ error.
Logic
Runtime
Lexcial
Syntax
During the execution of a program, entering a String when an integer is expected is an example of a ______________ error.
Runtime
Lexcial
Logic
Syntax
What is printed?
(a)
A switch statement is useful when your program logic contains a chain of ______.
if else statements
variable declarations
method calls
parameters
loops
The type of parameter where changes by the method DO affect the original data.
Formal parameter
Value parameter
Actual parameter
Reference parameter
What is printed?
(a)
Select the choice representing the final value of this Boolean expression.
TRUE AND FALSE OR TRUE XOR FALSE
True
False
What is printed?
(a)
Which choice shows the correct parameter signature for the doStuff method header based on the final output shown below?
passed_by_reference int x, passed_by_reference y
passed_by_reference int x, passed_by_value y
passed_by_value int x, passed_by_value y
passed_by_value int x, passed_by_reference y
