Computer Science II Mock Exam - 766 Verified Questions

Page 1


Computer Science II

Mock Exam

Course Introduction

Computer Science II is a continuation of introductory computer science principles, focusing on advanced programming techniques, data structures, and algorithmic problem solving. The course covers topics such as arrays, linked lists, stacks, queues, trees, recursion, sorting and searching algorithms, and object-oriented programming concepts like inheritance and polymorphism. Students will develop proficiency in designing, implementing, testing, and debugging complex software solutions while building a deeper understanding of computational thinking and software engineering practices. This course prepares students for more specialized study in computer science and related fields.

Recommended Textbook

Starting out with C++ Early Objects 9th Edition by Tony Gaddis

Available Study Resources on Quizplus

19 Chapters

766 Verified Questions

766 Flashcards

Source URL: https://quizplus.com/study-set/1486

Page 2

Chapter 1: Introduction to Computers and Programming

Available Study Resources on Quizplus for this Chatper

40 Verified Questions

40 Flashcards

Source URL: https://quizplus.com/quiz/29517

Sample Questions

Q1) IDE stands for internal data engine.

A)True

B)False

Answer: False

Q2) The purpose of a memory address is

A) to identify the location of a memory cell.

B) to allow multitasking.

C) to prevent multitasking.

D) to locate a program.

E) none of the above.

Answer: A

Q3) The purpose of the compiler is to convert object code into source code.

A)True

B)False

Answer: False

Q4) Once a value has been stored in a variable it cannot be changed.

A)True

B)False

Answer: False

To view all questions and flashcards with answers, click on the resource link above. Page 3

Chapter 2: Introduction to C Plus Plus

Available Study Resources on Quizplus for this Chatper

40 Verified Questions

40 Flashcards

Source URL: https://quizplus.com/quiz/29528

Sample Questions

Q1) A C++ character literal is enclosed in ______ quotation marks, whereas a string literal is enclosed in ______ quotation marks.

A) double, single

B) triple, double

C) open, closed

D) single, double

E) no, some

Answer: D

Q2) #include <iostream> is an example of a(n)

A) comment.

B) I/O statement.

C) preprocessor directive.

D) stream directive.

E) compiler option.

Answer: C

Q3) C++ is a case-sensitive language.

A)True

B)False

Answer: True

To view all questions and flashcards with answers, click on the resource link above.

Page 4

Chapter 3: Expressions and Interactivity

Available Study Resources on Quizplus for this Chatper

40 Verified Questions

40 Flashcards

Source URL: https://quizplus.com/quiz/29529

Sample Questions

Q1) The following pair of C++ statements is legal. const double taxRate; taxRate = .05;

A)True

B)False

Answer: False

Q2) ________ causes a program to wait until information is typed at the keyboard and the Enter key is pressed.

A) An input device

B) The cin object

C) The cout object

D) A preprocessor

E) Nothing Answer: B

Q3) The following statement sets sum1, sum2, and sum3 all to zero. sum1 = sum2 = sum3 = 0;

A)True

B)False

Answer: True

To view all questions and flashcards with answers, click on the resource link above.

Page 5

Chapter 4: Making Decisions

Available Study Resources on Quizplus for this Chatper

40 Verified Questions

40 Flashcards

Source URL: https://quizplus.com/quiz/29530

Sample Questions

Q1) When a program lets the user know that an invalid menu choice has been made, this is an example of

A) input validation.

B) output validation.

C) menu reselection.

D) invalidation.

E) being user unfriendly.

Q2) If the sub-expression on the left side of an || operator is True, the expression on the right side will not be checked.

A)True

B)False

Q3) The following C++ test checks if the variable child is in the range 3 - 12. if (child >= 3 && <= 12)

A)True

B)False

Q4) Relational expressions and logical expressions are both Boolean, which means they evaluate to True or false.

A)True

B)False

To view all questions and flashcards with answers, click on the resource link above. Page 6

Chapter 5: Looping

Available Study Resources on Quizplus for this Chatper

40 Verified Questions

40 Flashcards

Source URL: https://quizplus.com/quiz/29531

Sample Questions

Q1) The ideal type of loop to use for repeating a menu is a(n) ________ loop.

A) do-while

B) for

C) sentinel controlled

D) infinite

E) nested

Q2) The statements in the body of a do-while loop are executed

A) exactly once.

B) at least once.

C) only if the test condition is initially True.

D) until the test condition becomes True.

E) forever until the user hits the break key.

Q3) The block of code in the body of a while statement can contain an unlimited number of statements, provided they are enclosed in a set of braces.

A)True

B)False

Q4) Before beginning to add value to it, an accumulator should be initialized to 1.

A)True

B)False

To view all questions and flashcards with answers, click on the resource link above. Page 7

Chapter 6: Functions

Available Study Resources on Quizplus for this Chatper

40 Verified Questions

40 Flashcards

Source URL: https://quizplus.com/quiz/29532

Sample Questions

Q1) Although global variables can be useful, it is considered good programming practice to restrict your use of them.

A)True

B)False

Q2) Functions are ideal for use in menu-drive programs. When a user selects a menu item, the program can call an appropriate function to carry out the user's choice.

A)True

B)False

Q3) A(n) ________ is information that is passed to a function, and a(n) ________ is a special variable that receives and holds that information.

A) function call, function header

B) function prototype, function header

C) parameter, argument

D) argument, parameter

E) formal argument, actual argument

Q4) In C++ global and local numeric variables are initialized to zero by default.

A)True

B)False

To view all questions and flashcards with answers, click on the resource link above. Page 8

Chapter 7: Introduction to Classes and Objects

Available Study Resources on Quizplus for this Chatper

40 Verified Questions

40 Flashcards

Source URL: https://quizplus.com/quiz/29533

Sample Questions

Q1) A C++ member function that sets or changes the value stored in a member variable is called

A) an accessor.

B) a mutator.

C) a user.

D) a get function.

E) an updater.

Q2) If Circle is the name of a class, which of the following statements would create a Circle object named myCircle?

A) myCircle Circle;

B) myCircle Circle();

C) Circle myCircle;

D) Circle myCircle();

E) None of the above

Q3) A structure has member variables, like an object, but they are usually all public and accessed directly with the dot operator, instead of by calling member functions.

A)True

B)False

To view all questions and flashcards with answers, click on the resource link above.

9

Chapter 8: Arrays

Available Study Resources on Quizplus for this Chatper

40 Verified Questions

40 Flashcards

Source URL: https://quizplus.com/quiz/29534

Sample Questions

Q1) When an array is passed to a function, it is actually ________ the array that is passed.

A) the starting memory address of B) a copy of all the values in C) the value stored in the first element of D) the data type and size of E) the data type and name of

Q2) If the scores array is defined like this: int scores[ ]= {4, 7, 4, 8, 9}; What will the following statement display?

Cout << scores[4];

A) 4

B) 7

C) 8

D) 9

E) the first four scores

Q3) An individual array element can be processed or passed to a function just like a regular C++ variable.

A)True

B)False

To view all questions and flashcards with answers, click on the resource link above. Page 10

Chapter 9: Searching, Sorting, Algorithm Analysis

Available Study Resources on Quizplus for this Chatper

40 Verified Questions

40 Flashcards

Source URL: https://quizplus.com/quiz/29535

Sample Questions

Q1) A(n) ________ algorithm arranges data into some order.

A) sorting

B) searching

C) ordering

D) linear

E) binary

Q2) Sorted data can be ordered

A) from lowest to highest value.

B) from highest to lowest value.

C) using a bubble sort algorithm.

D) using a selection sort algorithm.

E) in all of the above ways.

Q3) To find a value that is in an unordered array of 100 items, how many values must linear search examine on average?

A) 7

B) 10

C) 50

D) 100

E) 101

To view all questions and flashcards with answers, click on the resource link above. Page 11

Chapter 10: Pointers

Available Study Resources on Quizplus for this Chatper

62 Verified Questions

62 Flashcards

Source URL: https://quizplus.com/quiz/29518

Sample Questions

Q1) When the ________ is placed in front of a variable name, it returns the address of that variable.

A) asterisk ( * )

B) conditional operator

C) ampersand ( & )

D) semicolon ( ; )

E) None of the above

Q2) Which of the following statements is not valid C++ code?

A) int ptr = &num1;

B) int ptr = int *num1;

C) float num1 = &ptr2;

D) All of the above are valid.

E) All of the above are invalid.

Q3) When you work with a dereferenced pointer, you are actually working with A) a variable whose memory has been deallocated.

B) a copy of the value pointed to by the pointer variable.

C) the variable whose address is stored in the pointer variable.

D) All of the above

E) None of the above

To view all questions and flashcards with answers, click on the resource link above. Page 12

Chapter 11: More About Classes and Object-Oriented Programming

Available Study Resources on Quizplus for this Chatper

70 Verified Questions

70 Flashcards

Source URL: https://quizplus.com/quiz/29519

Sample Questions

Q1) An ________ operator can work with programmer-defined data types. A) inline

B) unconditional

C) overloaded

D) undefined

E) None of the above

Q2) When a class contains a pointer to dynamically allocated memory, it is a good idea to equip the class with

A) a dynamically allocated constructor.

B) a copy constructor.

C) a static constructor and an overloaded comparison operator.

D) an inline constructor.

E) None of the above

Q3) The library function move() can be used to

A) transfer ownership of a managed object from one unique_ptr object to another.

B) move the contents of a dynamically allocated block of memory to another address.

C) move the contents of any block of memory to another address.

D) make a raw pointer point to a different memory location.

To view all questions and flashcards with answers, click on the resource link above. Page 13

Chapter 12: More on C-Strings and the String Class

Available Study Resources on Quizplus for this Chatper

40 Verified Questions

40 Flashcards

Source URL: https://quizplus.com/quiz/29520

Sample Questions

Q1) The ________ function converts an integer to a string and returns the string value.

A) string stoint(int i)

B) string strtoint(int i)

C) string strint(int i)

D) string to_string(int i)

E) None of the above

Q2) To declare a C-string, you should use the type expression string *.

A)True

B)False

Q3) The following statement declares a string object and initializes it to "Once upon a time".

string theString("Once upon a time");

A)True

B)False

Q4) Although C++ provides ample library functions to handle numeric values, we must write all of our own functions to manipulate character values.

A)True

B)False

To view all questions and flashcards with answers, click on the resource link above.

14

Chapter 13: Advanced File and Io Operations

Available Study Resources on Quizplus for this Chatper

40 Verified Questions

40 Flashcards

Source URL: https://quizplus.com/quiz/29521

Sample Questions

Q1) The ________ may be used to read information from a file.

A) cout object

B) the stream insertion operator

C) file.in macro

D) stream extraction operator

E) None of the above

Q2) The ________ function can be used to store binary data to a file.

A) binary.out

B) write

C) put

D) dataout(binary)

E) None of the above

Q3) The ________ member function reports when the end of a file has been found.

A) end()

B) stop()

C) done()

D) eof()

E) None of the above

To view all questions and flashcards with answers, click on the resource link above. Page 15

Chapter 14: Recursion

Available Study Resources on Quizplus for this Chatper

20 Verified Questions

20 Flashcards

Source URL: https://quizplus.com/quiz/29522

Sample Questions

Q1) A recursive function cannot call a function other than itself.

A)True

B)False

Q2) Recursion can be used to

A) compute factorials.

B) find the greatest common divisor of two integers (GCD).

C) program things that cannot be programmed without recursion.

D) All of the above

E) Both A and B, but not C

Q3) The QuickSort algorithm was developed in 1960 by

A) Bjarne Stroustrup.

B) Tony Gaddis.

C) C.A.R. Hoare.

D) Judy Walters.

E) None of the above

Q4) The speed and amount of memory available to modern computers diminishes the performance impact of the overhead of recursion so much that for many applications, this overhead is not noticeable.

A)True

B)False

Page 16

To view all questions and flashcards with answers, click on the resource link above.

Chapter 15: Polymorphism and Virtual Functions

Available Study Resources on Quizplus for this Chatper

22 Verified Questions

22 Flashcards

Source URL: https://quizplus.com/quiz/29523

Sample Questions

Q1) ________ to a base class may be assigned the address of a derived class object.

A) Access specifiers

B) Static members

C) Private members

D) Pointers

E) None of the above

Q2) When the compiler binds a call to a member function using only information available at compile time, the compiler is said to use ________ binding.

A) local

B) safe

C) static

D) dynamic

E) None of the above

Q3) When more than one class is derived from a base class, the situation is called A) polymorphism.

B) population.

C) multiplicity.

D) encapsulation.

E) None of the above

To view all questions and flashcards with answers, click on the resource link above. Page 17

Chapter 16: Exceptions, Templates, and the Standard

Template Library Stl

Available Study Resources on Quizplus for this Chatper

40 Verified Questions

40 Flashcards

Source URL: https://quizplus.com/quiz/29524

Sample Questions

Q1) A function template's prefix contains ________ in angled brackets.

A) one or more generic data types

B) the function definition

C) constant values

D) the function's return type

E) None of the above

Q2) A(n)________ is a class that stores data and organizes it in some fashion.

A) iterator

B) container

C) template

D) box

E) None of the above

Q3) The bad_alloc exception is thrown

A) when program code encounters a bad memory location.

B) by the new operator.

C) when you forget to free memory with the delete operator.

D) only when the program contains a catch block.

E) None of the above

To view all questions and flashcards with answers, click on the resource link above. Page 18

Chapter 17: Linked Lists

Available Study Resources on Quizplus for this Chatper

38 Verified Questions

38 Flashcards

Source URL: https://quizplus.com/quiz/29525

Sample Questions

Q1) The STL implementation of a linked list is a class called

A) LinkedList.

B) DynamicList.

C) dequeue.

D) list.

E) None of the above

Q2) Nodes in a linked list are stored in contiguous memory.

A)True

B)False

Q3) The ________ of a linked list points to the first node in the list.

A) starter

B) head

C) tail

D) declaration

E) None of the above

Q4) In a non-empty list, there must be exactly one list item with no successor.

A)True

B)False

To view all questions and flashcards with answers, click on the resource link above. Page 19

Chapter 18: Stacks and Queues

Available Study Resources on Quizplus for this Chatper

36 Verified Questions

36 Flashcards

Source URL: https://quizplus.com/quiz/29526

Sample Questions

Q1) The ________ operation allows an item to be removed from a stack.

A) push

B) pop

C) delete

D) remove

E) None of the above

Q2) A ________ is a container that provides quick access to elements at the front and the back of the list.

A) stack

B) queue

C) deque

D) All of the above

E) None of the above

Q3) The STL provides containers for deque and queue.

A)True

B)False

Q4) Enqueue and dequeue are the two most common stack operations.

A)True

B)False

To view all questions and flashcards with answers, click on the resource link above. Page 20

Chapter 19: Binary Trees

Available Study Resources on Quizplus for this Chatper

38 Verified Questions

38 Flashcards

Source URL: https://quizplus.com/quiz/29527

Sample Questions

Q1) Deleting a leaf node from a binary search tree is not difficult. Deleting a non-leaf node requires several steps.

A)True

B)False

Q2) An operation that can be performed on a binary search tree is

A) insertion of new value.

B) searching the tree for the occurrence of a given value.

C) removing a value stored in the tree.

D) All of the above

E) None of the above

Q3) Visiting all nodes of a binary tree in some methodical fashion is known as A) climbing the tree.

B) traversing the tree.

C) walking through tree.

D) branching out along the tree.

E) None of the above

Q4) Output will be the same if you use inorder, postorder, or preorder traversals to print the values stored in a binary tree.

A)True

B)False

To view all questions and flashcards with answers, click on the resource link above. Page 21

Turn static files into dynamic content formats.

Create a flipbook
Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.