
Procedures

Quiz
•
Computers
•
12th Grade
•
Hard
Ms Seccafico
Used 99+ times
FREE Resource
6 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
In the following procedure, the parameter str is a string and the parameter num is a number.
PROCEDURE printArgs(str, num)
{
DISPLAY(num)
DISPLAY(str)
DISPLAY(num)
}
Consider the following code segment.
printArgs("**", 1)
printArgs("*", 2)
What is displayed as a result of executing the code segment?
1 * 1 2 ** 2
1 ** 1 2 * 2
* 1 * ** 2 **
** 1 ** * 2 *
2.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
Consider the following procedures.
PROCEDURE proc1(str)
{
DISPLAY(str)
DISPLAY("happy")
}
PROCEDURE proc2(str1, str2)
{
proc1(str2)
DISPLAY(str1)
}
What is displayed as a result of the procedure call proc2("birthday", "to you") ?
birthday happy to you
birthday happy birthday
to you birthday happy
to you happy birthday
3.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
Consider the following procedure.
PROCEDURE doSomething(num1, num2)
{
DISPLAY(num1)
RETURN(num1)
DISPLAY(num2)
}
Consider the following statement.
DISPLAY(doSomething(10, 20))
What is displayed as a result of executing the statement above?
10 10
10 20
10 10 20
10 20 10
4.
MULTIPLE SELECT QUESTION
1 min • 1 pt
Which of the following are benefits of procedural abstraction?
Select two answers.
Procedural abstraction prevents programmers from accidentally using the intellectual property of other programmers.
Procedural abstraction eliminates the need for programmers to document their code.
Procedural abstraction makes it easier for people to read computer programs.
Procedural abstraction provides an opportunity to give a name to a block of code that describes the purpose of the code block.
5.
MULTIPLE CHOICE QUESTION
2 mins • 1 pt
A student is developing a program that allows users to look up the definitions of words that appear in a book.
The student plans to perform a large number of searches through a dictionary containing words and their definitions. The student will use a procedure written by a computer scientist to quickly search the dictionary (and knows that the procedure will return a definition if one is available). The student cannot modify the search procedure written by the computer scientist but can call the procedure by supplying a word.
Which of the following is a true statement about the student’s use of the computer scientist’s search procedure?
The student is changing the search procedure’s internal abstractions.
The student is modifying the search procedure to take a definition as an argument and return the corresponding word.
The student is reusing the computer scientist’s procedural abstraction by knowing what the procedure does without knowing how it does it.
The student is reusing the computer scientist’s procedural abstraction by using duplicate code each time a search needs to occur.
6.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
A student wrote the following procedure to calculate the sum of the integers from 1 to 5.
The student later decides to modify the procedure to calculate the sum of the integers from 1 to max, which represents any positive integer greater than 1.
Which of the following changes should be made to the procedure to meet the student’s goal?
I. The procedure should take max as an input parameter. II. The condition in the REPEAT UNTIL block should be changed to count > max.
III. The condition in the REPEAT UNTIL block should be changed to max < 5.
I only
II only
I and II
I and III
Similar Resources on Wayground
10 questions
AP CSP Identifying Errors

Quiz
•
9th - 12th Grade
10 questions
WK 9 variable

Quiz
•
12th Grade
10 questions
PLTW CSE L1 Vocab P1/2

Quiz
•
9th - 12th Grade
10 questions
C# Programming Quiz

Quiz
•
12th Grade
9 questions
Access: Creating Reports

Quiz
•
9th - 12th Grade
10 questions
KS3 Computational Thinking

Quiz
•
KG - University
5 questions
EOP - Practice Quiz 2

Quiz
•
12th Grade
10 questions
Programming Paradigms

Quiz
•
12th Grade
Popular Resources on Wayground
15 questions
Hersheys' Travels Quiz (AM)

Quiz
•
6th - 8th Grade
20 questions
PBIS-HGMS

Quiz
•
6th - 8th Grade
30 questions
Lufkin Road Middle School Student Handbook & Policies Assessment

Quiz
•
7th Grade
20 questions
Multiplication Facts

Quiz
•
3rd Grade
17 questions
MIXED Factoring Review

Quiz
•
KG - University
10 questions
Laws of Exponents

Quiz
•
9th Grade
10 questions
Characterization

Quiz
•
3rd - 7th Grade
10 questions
Multiply Fractions

Quiz
•
6th Grade