# Study Guide

## Field 054: Computer Science Sample Multiple-Choice Questions

##### Competency 0001 Understand problem solving and algorithm development.

The iterative design process would be most appropriately used in which of the following situations?

1. large budget for project designers is available.
2. A small project must be completed quickly by a single person.
3. The project is well defined and has strict specifications.
4. The major project requirements are known but details can evolve over time.
Correct Response: D.
The iterative design process is a cyclic approach to designing, testing, analyzing, and refining a project. In each iteration, modifications can be made, incorporating details that change during the course of the project. Once the modifications are made, the project is again tested, analyzed, and refined.

##### Competency 0002 Understand characteristics of algorithms.

Use the pseudocode below to answer the question that follows.

function left parenthesis list right parenthesis slash slash index of a list starts at zero slash slash
len equals list.length left parenthesis right parenthesis slash slash finds the length of list slash slash
for left parenthesis i equals 0, i is less than or equal to len minus 1, i equals i plus 1 right parenthesis
print left parenthesis answer right parenthesis

What will function left parenthesis left bracket 3, 4, 5 right bracket right parenthesis print?

1. 3
2. 4
3. 5
4. 6
Correct Response: B.
There are 3 elements in the list, so len equals 3 and the for loop will iterate when i equals 0, 1, 2. At each iteration, the list element is added to the value of answer, which is initially assigned the value of 0. When the loop is complete, the quotient of answer and len is computed. The trace table for the loop is shown below.
Initial Loop 1 Loop 2 Loop 3 i answer+ list[i]answer plus list left bracket i right bracket answer 0 0 0 0 0+30 plus 3 3 1 3+43 plus 4 7 2 7+57 plus 5 12

When the loop terminates, answer equals 12 and len equals 3, therefore 12 slash 3 equals 4.

##### Competency 0003 Understand data analysis, modeling, and simulation.

Students have access to a data set that relates the air pressure as measured by a barometer to the amount of precipitation (rain) for the area in which they live. The students would like to create a computer program to analyze the data to determine whether knowing air pressure can help predict rain. Building this program requires application of which of the following mathematical concepts?

2. complex numbers
3. regression models
4. Pythagorean triples
Correct Response: C.
In statistics, regression models are used to analyze the relationship between a dependent variable and an independent variable. They are commonly used to make predictions by estimating the expected value of the dependent value, in this case the chance of rain, given the independent variable (air pressure). Linear regression models can produce the equation of the line that best fits the data, along with a measure of how well the two variables are correlated.

##### Competency 0004 Understand programming concepts and program design and development.

When a smartphone manufacturer releases a new feature, such as fingerprint scanning, the manufacturer needs to provide developers with the ability to incorporate this new feature into their software. This is typically accomplished through the use of:

1. Open Systems Interconnection (OSI) model.
2. graphical user interface (GUI).
3. application programming interface (API).
Correct Response: C.
An API is a set of requirements that determine how one application (app) can talk to another. APIs allow developers limited access to a program's internal functions. In this case, a smartphone manufacturer would typically provide enough access for mobile device app developers to be able to integrate the fingerprint scanner into their apps without exposing all of the fingerprinting application code.

##### Competency 0005 Understand characteristics and uses of data types.

Use the information below to answer the question that follows.

// string.characterAt(i), returns the character at index i. //
// String index begins at zero. //

email = "last.first@school.edu"

slash slash string.characterAt left parenthesis i right parenthesis, returns the character at index i period slash slash
slash slash String index begins at zero period slash slash

email equals quote last period first at school period edu"

Which of the following methods will return @?

1. email period characterAt left parenthesis 8 right parenthesis
2. email period characterAt left parenthesis 9 right parenthesis
3. email period characterAt left parenthesis 10 right parenthesis
4. email period characterAt left parenthesis 11 right parenthesis
Correct Response: C.
In the string last period first at school period edu, the at is the 11th character in the string. However, since the string index begins at 0, the index of the at is 10.

##### Competency 0006 Understand operators and control structures.

Use the information below to answer the question that follows. The diagram is a 7 by 7 square grid. A dark line represents the path taken by a robot as seen from above. The line starts in the lower left corner, goes horizontally to the right one square, up one square, to the right one square, up one square, and continues in this pattern to the square in the fifth column over and fifth row to the right. The line ends at this point with an arrow pointing up.

The diagram above shows the path taken by a robot that starts facing in the positive y-direction at the point (0, 0) on a coordinate grid. It can move forward n units (Forward n), turn left 90 degrees (Turn Left), or turn right 90 degrees (Turn Right). Each grid line in the graphic represents 10 units.

Which of the following pseudocode segments will create the path shown in the diagram?

1. i equals 2
while left parenthesis i is less than 12 right parenthesis
if i is even
Turn Right
Forward 10
else
Turn Left
Forward 10
i equals i plus 1

2. i equals 2
while left parenthesis i is less than or equal to 12 right parenthesis
if i is even
Turn Right
Forward 10
else
Turn Right
Forward 10
i equals i plus 1

3. i equals 2
while left parenthesis i is less than 12 right parenthesis
if i is even
Forward 10
Turn Right
else
Forward 10
Turn Left
i equals i plus 1

4. i equals 2
while left parenthesis i is less than or equal to 12 right parenthesis
if i is even
Forward 10
Turn Right
else
Forward 10
Turn Left
i equals i plus 1
Correct Response: A.
In this question, the robot begins at (0, 0), facing in the positive y-direction. To follow the path, the robot must first turn to the right and move 10 units in the positive x-direction, then turn left and move 10 units in the positive y-direction. This is accomplished by turning right when i is even and left when i is odd. Since i begins at 2, and the robot travels for 10 segments, the values for i will be 2 through 11; the loop will not execute once i equals 12.

##### Competency 0007 Understand concepts of object-oriented design and programming.

Use the pseudocode below to answer the question that follows.

CLASS Flower

private integer numOfPetals
private string color
private bloom left parenthesis right parenthesis
public grow left parenthesis right parenthesis

SUBCLASS Rose inherits from Flower

Rose left parenthesis numOfPetals, color right parenthesis

MAIN

Rose r1 equals Rose left parenthesis 5, left quote red right quote right parenthesis

Which of the following demonstrates how to access an element of the class Rose?

1. r1 period numOfPetals
2. r1 period color
3. r1 period bloomleft parenthesis right parenthesis
4. r1 period growleft parenthesis right parenthesis
Correct Response: D.
In the program, r1 is an object, or instance of class Rose. Rose is a subclass of Flower, and inherits from it. Since Rose is a subclass, it can only access the public variables and methods, in this case the public method, grow left parenthesis right parenthesis. Therefore, r1 period grow left parenthesis right parenthesis is the only way to access an element of r1.

##### Competency 0008 Understand terminology and concepts related to computing systems.

The hexadecimal number 4F is equivalent to what decimal number?

1. 19
2. 79
3. 154
4. 415
Correct Response: B.
In hexadecimal notation, the symbols 0 to 9 are used to represent the numbers 0 to 9 and the symbols A to F represent the numbers 10 to 15. Hexadecimal is a base-16 system. The hexadecimal number 4F can be converted to a decimal number as follows: 4 times 16 superscript 1 plus 15 times 16 superscript 0 equals 4 left parenthesis 16 right parenthesis plus 15 left parenthesis 1 right parenthesis equals 64 plus 15 equals 79.

##### Competency 0009 Understand networks and the Internet.

A client-side scripting language would most likely be used for which of the following tasks?

1. rerouting messages
2. storing information in a database
3. adding interactivity to a web page
4. executing code on a web server
Correct Response: C.
In client-side scripting, source code is transferred from the web server to a user's computer over the Internet and run directly in the browser. Client-side scripting allows a web page to behave differently in response to mouse or keyboard actions. Rollover buttons, pop-up balloons, and filters for search criteria are all examples of interactive features that can be produced with client-side scripting.

##### Competency 0010 Understand social and global issues related to computer technology.

Which of the following statements best describes how Grace Hopper contributed to the field of computer science?

1. She combined transistors, capacitators, and other components onto a single chip.
2. She designed the logic gate architecture to perform various computational operations.
3. She wrote the source code for the protocol used for early networks.
4. She developed one of the first high-level programming languages.
Correct Response: D.
Grace Hopper (1906 to 1992) was a rear admiral in the United States Navy and a computer scientist. She invented one of the first compiler-related tools and her work on machine-independent programming languages led to the development of COBOL.

##### Competency 0011 Understand effective learning environments.

A computer science curriculum that begins with a unit on problem solving instead of beginning with computer programming is likely to foster inclusive learning primarily because beginning with problem solving:

1. provides students with opportunities to succeed regardless of their previous coding experience.
2. teaches students the importance of working collaboratively in computer science.
3. allows students without previous coding experience to take extra time to pre-learn code syntax.
4. helps students of all backgrounds and abilities determine whether computer science is of personal interest.