Study Guide

Field 205: Computer Science 
Sample Multiple-Choice Questions

Recommendation for individuals using a screenreader: please set your punctuation settings to "most."

Some of these test questions contain pseudocode. You may wish to adjust the punctuation level of your screen reader.

Expand All | Collapse All

Each multiple-choice question has four answer choices. Read each question and its answer choices carefully and choose the ONE best answer.

During the test you should try to answer all questions. Even if you are unsure of an answer, it is better to guess than not to answer a question at all. You will NOT be penalized for choosing an incorrect response.

Objective 0001
Understand the problem-solving process.

1. The stepwise refinement method of software development is a top-down design process in which the general task is broken up into several subtasks. Each subtask is then broken up into smaller subtasks and the process continues until the program is completely designed. The design is given to programmers who write the code for the various subtasks. Compared to this method of software development, a more iterative method would allow developers to:

  1. work on different portions of the program in separate locations concurrently.
  2. rapidly create a finished program that requires little testing or debugging.
  3. use a greater variety of programming tools and aids throughout development.
  4. more easily adapt and change course in response to unforeseen problems.
Answer and Rationale. Enter to expand or collapse. Answer expanded
Correct Response: D.
In the iterative method for software development, code is developed through a process of successive approximations. The basic code is written, tested, and revised multiple times throughout the development process. Sections of the code may be revisited and rewritten based on feedback from a variety of sources. The process is cyclical in nature, where previous design decisions may be revisited and rewritten. Therefore, an iterative design method allows developers to more easily adapt and change course in response to unforeseen problems.

Objective 0001
Understand the problem-solving process.

2. Use the information below to answer the question that follows.

//This program takes two non-zero decimal numbers as input and
//outputs their quotient.

print("Input first number")
num1 = getInputFromUser
print("Input second number")
num2 = getInputFromUser

print("Their quotient is: " findQuotient(num1, num2))

findQuotient(num1, num2)
return num1/num2

A student uses the above approach for writing a computer program. This style of programming uses ideas that are most similar to which of the following mathematical concepts?

  1. functions
  2. proportions
  3. equations
  4. commutativity
Answer and Rationale. Enter to expand or collapse. Answer expanded
Correct Response: A.
The pseudocode shown takes two non-zero decimal numbers as input from a user and returns their quotient, which is the result of division of the first number by the second number. The code findQuotient(num1, num2) is an example of a method, which is also known as a function. The method has two parameters, num1 and num2. The user inputs the arguments for the two parameters, which are passed to the method. This is very similar to the concept of mathematical function (in this case, a mathematical function of two variables).

Objective 0002
Understand types and characteristics of algorithms.

3. Students are working on an algorithm to determine whether a word is a palindrome or not; that is, whether the word has the same spelling forward as it does backward. Examples of palindromes are noon, civic, and radar. The students come up with the following algorithm.

This approach to solving the problem is an example of which of the following programming concepts?

  1. recursion
  2. encapsulation
  3. sequence
  4. inheritance
Answer and Rationale. Enter to expand or collapse. Answer expanded
Correct Response: A.
Recursive algorithms repeatedly break a problem into smaller subproblems that are similar to each other and use the same process to solve each subproblem. For example, suppose the given algorithm is going to check if the word radar is a palindrome. It will check first and last letters, in this case r. Since they are the same letter, they are removed, leaving ada. The algorithm then treats ada as a new word and repeats the same process. Since the first and last letters, a, are the same, it removes them from the word, leaving the letter d. The program then stops and prints "It's a palindrome!" since there is only one letter, d, remaining. This is characteristic of an algorithm that uses recursion.

Objective 0002
Understand types and characteristics of algorithms.

4. A student starts to sort a list using the following process.

Given the list of numbers [13, 6, 7, 3, 4]:

If the process continues as described, what is the total number of exchanges needed to completely sort the list from least to greatest?

  1. 2
  2. 3
  3. 4
  4. 5
Answer and Rationale. Enter to expand or collapse. Answer expanded
Correct Response: C.
Applying the given algorithm to the list results in the following: The smallest number in the list is 3. Exchanging it with the number in the left-most position (13) results in [3, 6, 7, 13, 4], which is one exchange. The second exchange will involve exchanging 4 and 6, resulting in [3, 4, 7, 13, 6], followed by [3, 4, 6, 13, 7]. Finally, the fourth exchange will produce the sorted list [3, 4, 6, 7, 13].

Objective 0003
Understand object-oriented program design.

5. Use the information below to answer the question that follows.

CLASS Text
firstWord: string
secondWord: string

join()
print(firstWord + "+secondWord") //+ is the concatenation operator

Text(firstWord, secondWord)

MAIN
Text t1 = Text("Good", "Day")

Given the CLASS Text as defined above, which of the following will print Good Day to the screen?

  1. t1
  2. join(t1)
  3. t1.join()
  4. Text.join()
Answer and Rationale. Enter to expand or collapse. Answer expanded
Correct Response: C.
The pseudocode shown is an example of a class in object-oriented programming. The class is named Text. Text has two class string variables (firstWord and secondWord), a method named join(), and a constructor, Text(firstWord, secondWord). In Main, Text constructs an object (or an instance of the class) named t1 with string variables Good and Day. The method join() concatenates two strings and prints them to the screen. In order to print Good Day to the screen, it is necessary to call a method on t1. This is accomplished by using the dot notation t1.join().

Objective 0003
Understand object-oriented program design.

6. A programmer is writing a class called Account. Which of the following implementations of the CLASS Account best represents the use of encapsulation?

  1. CLASS Account
    private customerNumber: string
    private balance: float

    private setBalance()
    private getBalance()

  2. CLASS Account
    private customerNumber: string
    private balance: float

    public setBalance()
    public getBalance()

  3. CLASS Account
    public customerNumber: string
    public balance: float

    public setBalance()
    public getBalance()

  4. CLASS Account
    public customerNumber: string
    public balance: float

    private setBalance()
    private getBalance()

Answer and Rationale. Enter to expand or collapse. Answer expanded
Correct Response: B.
Encapsulation is involved in combining data and actions (methods) in a single unit and involves hiding the details of the program from the end user. An important way of accomplishing encapsulation is with variables and methods that use public and private access specifiers to hide information and control the how the data can be accessed within the program. The best way to achieve this goal is to make the class variable private and only accessible through public class methods. This ensures that the end user cannot directly access the data and allows restrictions to be placed on data values.

Objective 0004
Understand characteristics of various computational tools.

7. In programming, libraries are created to provide programmers with which of the following resources?

  1. an archive of the various versions of the language
  2. reusable classes and methods
  3. prewritten program documentation
  4. access to source code of the programming language
Answer and Rationale. Enter to expand or collapse. Answer expanded
Correct Response: B.
Many contemporary programming languages contain libraries, which are collections of classes and methods that can be accessed by the developer and reused in a development project. Having access to the language library's classes and methods allows for code reuse and makes the development process much less time consuming. Examples of libraries are classes for manipulating graphics, sound, files and directory structures, and libraries for creating programs that use graphical user interfaces (GUIs) such as windows, text boxes, and buttons.

Objective 0004
Understand characteristics of various computational tools.

8. Which of the following is the primary purpose of the interrupt property of an operating system?

  1. reading and writing data to storage disks
  2. managing virtual memory addressing
  3. halting program execution due to incorrect inputs
  4. transferring software execution in response to a request
Answer and Rationale. Enter to expand or collapse. Answer expanded
Correct Response: D.
An operating system is software that manages a computer system's resources, such as memory, input and output, and files and file structures. One role of operating system software is to manage multiple requests from system hardware or software. This is achieved using interrupts. When multiple requests for system resources occur at the same time, the operating system refers to a hierarchy of tasks and interrupts one process, saves its state to RAM, and executes the appropriate request. The system can return to the interrupted process at a later time. Transferring software execution in response to a request from another software program or a mouse click is an example of how an operation system would use an interrupt.

Objective 0005
Understand characteristics and functions of data types and data structures.

9. Use the information below to answer the question that follows.

//string dot character At open parens i close parens returns the string character at index i.
//string index starts at 0

s = "A B C D A B A"
j = 0
result = 0
while (j is less than 7)
if (s dot character At open parens j close parens == s dot character At open parens 0 close parens)
s dot character At open parens 0 close parens
result = result + 1
j equals j plus 1
return result

What will the above code return?

  1. 1
  2. 2
  3. 3
  4. 7
Answer and Rationale. Enter to expand or collapse. Answer expanded
Correct Response: C.
String s = "A B C D A B A and j and result are both initialized to zero. Using the comments to interpret how string dot character At open parens i close parens works and examining the code, it follows that s dot character At open parens 0 close parens = "A", since the index of a string starts at 0. Therefore, the code counts the number of occurrences of "A" in s. For example, when j = 0, s dot character At open parens 0 close parens == s dot character At open parens 0 close parens evaluates to true since "A" == "A", and it follows that result = 0 + 0 = 1. As the while loop executes, this statement will also be true when j = 4 and j = 6, so result will be incremented by 1 each time the if-statement is true. Hence, result = 3.

Objective 0005
Understand characteristics and functions of data types and data structures.

10. Use the information below to answer the question that follows.

//index of a list starts at zero
//list.length returns the length of list

list1 = ["portable","agile","extensive"]
n equals list 1 dot length
i = 1
while (i is less than n)
print open parens list 1 open bracket i close bracket plus open quote space close quote plus list 1 open bracket i minus 1 close bracket close parens
i equals i plus 1

What will the above code print?

  1. portable agile
  2. extensive agile
  3. portable agile
    extensive agile
  4. agile portable
    extensive agile
Answer and Rationale. Enter to expand or collapse. Answer expanded
Correct Response: D.
From the comments, it follows that list open bracket 0 close bracket is equal to portable, list open bracket 1 close bracket is equal to agile, list open bracket 2 close bracket is equal to extensive, and n is equal to 3. When i is equal to 1, the code will print list open bracket 1 close bracket plus open quote space close quote plus list open bracket 0 close bracket is equal to agile portable, since plus is the string concatenation operator. When i is equal to 2, the code will print list open bracket 2 close bracket plus open quote space close quote plus list open bracket 1 close bracket is equal to extensive agile.

Objective 0006
Understand program control.

11. A student wishes to search a database that contains information on books. The database can be searched by author, genre (e.g., fiction, biography), and year of publication. The student would like the search to return the following information.

Which of the following Boolean search queries would return these results using the Boolean search operators AND, OR?

  1. (biography AND Perez) AND 1972
  2. (biography OR Perez) AND 1972
  3. (biography AND Perez) OR 1972
  4. (biography OR Perez) OR 1972
Answer and Rationale. Enter to expand or collapse. Answer expanded
Correct Response: B.
The Boolean operator AND is used to narrow a search and the operator OR is used to expand a search. The query (biography OR Perez) will return all biographies and all books written by Perez. The query (biography OR Perez) AND 1972 will restrict the results to all biographies written in 1972 and all books written by Perez in 1972, which is the desired result.

Objective 0006
Understand program control.

12. Use the information below to answer the question that follows.

if (variable is greater than or equal to 9)
output = 'Set1'
else if (variable is greater than or equal to 8)
output = 'Set2'
else if (variable is greater than or equal to 7)
output = 'Set3'
else if (variable is greater than or equal to 6)
output = 'Set4'
else
output = 'Set5'
print(output)

If variable = 7.2, what will the code segment output?

  1. Set1
  2. Set2
  3. Set3
  4. Set4
Answer and Rationale. Enter to expand or collapse. Answer expanded
Correct Response: C.
If variable = 7.2, then (7.2 is greater than or equal to 9) is false and the computer will move to the next else statement. Likewise, (7.2 is greater than or equal to 8) is false and the next else statement will be evaluated. Finally, (7.2 is greater than or equal to 7) is a true statement so output is assigned Set3, the computer exits the conditional statement, and the value of output is printed.

Objective 0007
Understand software development and testing.

13. Which of the following questions is most likely to be addressed during the requirement gathering and analysis phase of the software development cycle?

  1. How should the system architecture be structured?
  2. How will product quality be determined?
  3. What are the needs of the end users of the product?
  4. Which computer language should be used to code the project?
Answer and Rationale. Enter to expand or collapse. Answer expanded
Correct Response: C.
The typical software development cycle begins with determining the requirements that the software must meet. The requirements documents describe the final software product and include the specifications for the software. The needs of the product's end users are included in the requirements documents, since it is the end users who determine how the software will be used, who will be using it, and what type of characteristics and functionality it should have.

Objective 0007
Understand software development and testing.

14. Use the information below to answer the question that follows.

The algorithm below is supposed to print the sum of the positive odd integers less than 10. The program contains an error.

num = 10
i = 0
sum = 0
while (i is less than num)
sum = sum + i
i = i + 2
print(sum)

Which of the following corrects the error?

  1. change "i = 0" to "i = 1"
  2. change "(i is less than num)" to "(i is less than or equal to num)"
  3. change "sum = sum + i" to "sum = sum + num"
  4. change "i = i + 2" to "i = i + 1"
Answer and Rationale. Enter to expand or collapse. Answer expanded
Correct Response: A.
The program is supposed to print the sum of the positive odd integers less than 10, or 25 since 1 + 3 + 5 + 7 + 9 = 25. To analyze the code, start the while loop with i = 0. Then sum = 0 and i will be increment to 2. When i = 2, sum = 0 + 2 and i will increment to 4. When i = 4, sum = 2 + 4 = 6; when i = 6, sum = 6 + 6 = 12; when i = 8, sum = 12 + 8 = 20, and when i = 10, the loop does not execute since 10 is not less than 10. The algorithm is finding the sum of the positive even integers less than 10, not the sum of the odd numbers, because it is starting with i = 0. To correct this problem, change "i = 0" to "i = 1". Then the algorithm will produce i = 1, sum = 1; i = 3, sum = 4; i = 5, sum = 9; i = 7, sum = 16; and finally, i = 9, sum = 25.

Objective 0008
Understand the structure and operations of the Internet.

15. Use the information below to answer the question that follows.

A connection to a Web server is opened.
A request is sent to the server.
Some processing is done by the server.
A response from the server is sent back.
The connection is closed.

The steps above describe a process that occurs during the implementation of which of the following technologies?

  1. lossless data compression algorithm
  2. network collision detection
  3. digital signal sampling
  4. hypertext transfer protocol
Answer and Rationale. Enter to expand or collapse. Answer expanded
Correct Response: D.
The information is a description of an HTTP Request, which is how a Web browser makes a request for information from a Web server. This is part of the hypertext transfer protocol, which is the set of rules that governs how information is exchanged over the World Wide Web.

Objective 0008
Understand the structure and operations of the Internet.

16. Which of the following is an example of phishing?

  1. sending an e-mail claiming an account was compromised in an effort to have someone use a personal password to log into a false site
  2. attaching a file containing a computer virus to an e-mail that appears to be legitimate
  3. using a password cracker method for finding the passwords to gain access to a computer network
  4. gaining access to a site by accessing "I forgot my password" and doing research to answer the security questions
Answer and Rationale. Enter to expand or collapse. Answer expanded
Correct Response: A.
Phishing is a form of social engineering, or a type of deception in which an effort is made to trick someone into disclosing personal information such as bank account passwords or social security numbers. Phishing involves sending a fraudulent e-mail that looks as if it originates from a legitimate source, such as a bank or a government agency. The e-mail directs the targeted person to log into a false Web site that resembles a bank's site, for example, thereby allowing the attacker to obtain the password to the actual bank account.

Objective 0009
Understand the social and global impact of computing.

17. A computer science teacher is concerned that some students in a class may not be using classroom technology in a manner that is consistent with the typical norms of digital citizenship. Which of the following is likely to be the most effective strategy for addressing this issue?

  1. instructing students to use their mobile devices to watch instructional videos related to the topic under study
  2. relating concepts in computer science as they arise during the course to the technologies used in mobile devices
  3. allowing students to access their mobile devices only when they have completed all classwork and homework
  4. having all students review and discuss the school's acceptable use policy
Answer and Rationale. Enter to expand or collapse. Answer expanded
Correct Response: D.
An acceptable use policy (AUP) is used by schools and businesses to describe the rules governing the appropriate use of technology. These policies forbid the use of computers for illegal activities and personal gain, and also include sections forbidding bullying and/or harassment. All students must sign the school's AUP and are held accountable for any violations. Students may need to review and discuss the policy from time to time to ensure they are maintaining the expected norms and behaviors when using technology.

Objective 0009
Understand the social and global impact of computing.

18. A primary difference between open-source software products and traditional software products is that open-source products:

  1. allow the user to modify the source code.
  2. run on a greater number of platforms.
  3. can be downloaded from multiple mirror Web sites.
  4. are delivered using a peer-to-peer distribution model.
Answer and Rationale. Enter to expand or collapse. Answer expanded
Correct Response: A.
An open-source software license allows the creator of the software to obtain a copyright while providing the software's source code, so users can study and learn from the software, distribute the software, and modify the source code. The goal of open-source software is to encourage collaboration in developing software as way of boosting creativity and driving innovation.

Objective 0010
Understand the learning environment and effective teaching and learning strategies in computer science.

19. While using a game development application, a student writes the code below to keep track of the player's score in the game and the number of lives of the player.

var score = 0
var lives = 5

Later in the game, the student wishes to print the score and writes the following.

print("score")

Which of the following best describes the student's error?

  1. The student is confusing the difference between a constant and a variable.
  2. The student is confusing the value of a variable and a string.
  3. The student is accessing a variable that is outside of the scope of a function.
  4. The student is using a local variable in place of a more generic global variable.
Answer and Rationale. Enter to expand or collapse. Answer expanded
Correct Response: B.
In the code shown, the variables store numerical data. When the student tries to print the score, the code will actually print the word score instead of the numerical value of the score. It is likely that the student is confusing the concept of the value of a variable and the concept of a string.

Objective 0010
Understand the learning environment and effective teaching and learning strategies in computer science.

20. A teacher is working with a student who is having difficulty writing for loops. The student consistently creates loops that tend to be off by one. Which of the following tasks will most likely help the student?

  1. drawing a flowchart that shows what happens after exiting the loop
  2. creating a trace table showing the values generated in the loop
  3. writing a while loop that performs the same function as the for loop
  4. inserting a break statement to terminate the loop at a particular value
Answer and Rationale. Enter to expand or collapse. Answer expanded
Correct Response: B.
Off-by-one errors are common in programming. Off-by-one errors in for loops sometimes arise due to incorrect counter values (e.g., 0 versus 1), improper use of inequality signs, or when using non-unit increments in the counter. Since the student consistently makes this type of error, it is likely that the student doesn't completely understand the looping mechanism. One of the best ways to help students better understand how loops work is to have them create trace tables that show the values generated by a loop (including the counter) as the loop executes. Trace tables help students gain a deeper and more intuitive understanding of the looping process.