Computer Science II Exam Practice Tests - 766 Verified Questions

Page 1


Computer Science II Exam Practice Tests

Course Introduction

Computer Science II builds upon foundational programming concepts introduced in introductory courses, focusing on advanced programming techniques and data structures. Students will explore topics such as object-oriented programming, recursion, linked lists, stacks, queues, trees, and sorting and searching algorithms. Emphasis is placed on problem-solving, software design, and code efficiency, with hands-on projects and assignments fostering practical skill development. By the end of the course, students will be able to analyze algorithm complexity, implement complex data structures, and develop modular, well-structured software solutions, preparing them for more advanced courses in computer science and software engineering.

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) The programmer usually enters source code into a computer using A) a preprocessor.

B) a compiler.

C) a linker.

D) a debugger.

E) none of the above.

Answer: E

Q2) The statements written by a programmer are called A) syntax.

B) object code.

C) source code.

D) language elements.

E) none of the above.

Answer: C

Q3) Most of the lines in a program contain something meaningful; however, some of the lines may contain nothing at all.

A)True

B)False

Answer: True

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) Which of the following definitions will allow the variable average to hold floating-point values?

A) float average;

B) double average;

C) auto average = 0.0;

D) All of the above

E) A and B, but not C

Answer: D

Q2) ________ must be included in a program in order to use the cout object.

A) Opening and closing braces

B) The iostream header file

C) A cout declaration

D) Strings

E) None of the above

Answer: B

Q3) A variable of the char data type can hold a set of characters like "January".

A)True

B)False

Answer: False

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 statement sets sum1, sum2, and sum3 all to zero. sum1 = sum2 = sum3 = 0;

A)True

B)False

Answer: True

Q2) What does the following C++ expression evaluate to?

6 - 6 / 3 + 3

A) 0

B) 3

C) 5

D) 7

E) None of the above

Answer: D

Q3) When an operator's operands are of different data types, such as int and double, C++ automatically converts one of them so that they are the same data type.

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) The ________ operator is used in C++ to test for equality.

A) =

B) <>

C) &&

D) ==

E) ||

Q2) If s1 and s2 are string objects, s1 == s2 is True when

A) s1 = "lion" and s2 = "lioness".

B) s1 = "dog" and s2 = "DOG".

C) s1 = "cat" and s2 = "cat ".

D) None of these because in each case one or more characters in the strings have different ASCII codes.

E) None of these because string objects cannot be compared with relational operators.

Q3) Assuming goodData is a Boolean variable, the following two tests are logically equivalent.

if (goodData == false) if (!goodData)

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) To use an output file in a C++ program you must

A) make sure the file already exists.

B) create a file stream object that will "point to" (i.e. reference) the file.

C) open the file.

D) do all of the above.

E) do B and C, but not A.

Q2) A variable that keeps a running total of data values is called a(n)

A) total.

B) sum.

C) accumulator.

D) counter.

E) loop control variable.

Q3) In order for a C++ program to read data from a file, A) the file must already exist.

B) the program must define a file stream object that can "point to" (i.e., reference) the file.

C) the program must open the file.

D) All of the above are required.

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

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) A ________ variable is declared outside all functions.

A) local

B) global

C) static

D) counter

E) constant

Q2) When a function just needs to use a copy of an argument passed to it, the argument should normally be passed by value.

A)True

B)False

Q3) A function can have zero to many parameters and either zero or one return value(s).

A)True

B)False

Q4) When only a copy of an argument is passed to a function, it is said to be passed A) by copy.

B) by reference.

C) informally.

D) by value.

E) by default value.

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) ADT stands for Algorithmic Data Type.

A)True

B)False

Q2) When the body of a member function is defined inside a class declaration, it is called a(n) ________ function.

A) static

B) global

C) inline

D) conditional E) constructor

Q3) A destructor is a member function that

A) is used to remove old unneeded objects.

B) causes the program to end.

C) is automatically called when an object is destroyed.

D) can only be called by the main function of a program.

E) None of the above.

Q4) A class must have exactly one constructor.

A)True

B)False

To view all questions and flashcards with answers, click on the resource link above. Page 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) The following array definition is legal because C++ allows arrays to be implicitly sized.

int grades[ ];

A)True

B)False

Q2) Which of the following statements will correctly carry out the operation stated in the comment to its right.

A) array 2 = array1 // Copy the elements of array 1 into array 2.

B) cout << array2 // Output the elements stored in array 2.

C) array2 = 5; // Place a 5 in each element of array2.

D) None of the above.

E) A and B, but not C.

Q3) An element of a two-dimensional array is referenced by the array name and two subscripts, first the element row number and then the element column number.

A)True

B)False

Q4) The range-based for loop may be used with arrays, but not with vectors.

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) We can estimate the ________ of an algorithm by counting the number of basic steps it requires to solve a problem.

A) number of lines of code

B) efficiency

C) run time

D) code quality

E) result

Q2) When sorting an array of objects or structures, one must decide which data item to sort on.

A)True

B)False

Q3) The advantage of a linear search is that

A) it is simple.

B) it is efficient.

C) it is fast.

D) it can be used on unordered data.

E) both A and D

Q4) Bubble sort and selection sort can also be used with STL vectors. A)True

B)False

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) Any time you use the new operator, it is good practice to

A) use delete afterwards to free the memory allocated by new.

B) use a preprocessor directive.

C) clear the data from the old operator

D) All of the above

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) If a variable occupies more than one byte of memory, its address is

A) the address of the last byte of storage allocated to it.

B) the average of the addresses used to store the variable.

C) the address of the first byte of storage allocated to it.

D) general delivery.

E) None of the above

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

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) The ________ is a special built-in pointer that is available to a class's instance member functions.

A) overloaded -> operator

B) this pointer

C) &constructor pointer

D) ~destructor *ptr

E) None of the above

Q2) It is possible to declare an entire class as a friend of another class.

A)True

B)False

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.

Q4) You may overload any C++ operator, and you may use the operator function to define non-standard operators, such as @ and ^.

A)True

B)False

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) A good way to convert a value of type double to a string is

A) use the ostringstream class.

B) use the strtodouble function.

C) use the doubletoa function.

D) use the doublestringstream class.

E) None of the above

Q2) The string class member function ________ will return the number of characters in the string object.

A) length()

B) length(string s)

C) capacity()

D) capacity(string s)

E) None of the above

Q3) The expression str1 < str 2 is True when

A) the string object str1 precedes the string str 2 in alphabetic order.

B) the string str1 converted to numeric form is less than the string str2 converted to numeric form.

C) the length of the string str1 is less than the length of the string str2.

D) the C-string "str1" precedes the C-string "str2" in alphabetic order.

E) None of the above

To view all questions and flashcards with answers, click on the resource link above. Page 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 ________ 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

Q2) The operating system records the information that tracks the end of the file

A) when a file is opened with ios::eof.

B) when a file is opened with ios::app.

C) when a file is closed.

D) when the program ends.

E) None of the above

Q3) All stream objects have ________ that indicate the condition of the stream.

A) error state bits

B) condition statements

C) markers

D) intrinsic error messages

E) None of the above

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

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 should be designed to stop making recursive calls when it reaches its

A) return statement.

B) base case.

C) closing curly brace.

D) last parameter.

E) None of the above

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

A)True

B)False

Q3) The quicksort algorithm works on the basis of A) three sublists.

B) two sublists and a pivot.

C) two pivots and a sublist.

D) three pivots.

E) None of the above

Q4) Indirect recursion means that a function calls itself several times.

A)True

B)False

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

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) If you want to make sure that member function of a class overrides another function in a base class, you should declare the function with the keyword

A) override.

B) public.

C) final.

D) private.

E) None of the above

Q2) Polymorphism is when ________ in a class hierarchy perform differently, depending upon the class of the object making the call.

A) base class constructors

B) derived class destructors

C) member functions

D) derived class constructors

E) None of the above

Q3) In C++ polymorphism is very difficult to achieve unless you also use inheritance.

A)True

B)False

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

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) The Standard Template Library (STL) contains templates for useful algorithms and data structures.

A)True

B)False

Q2) When an error occurs, an exception is A) created.

B) thrown.

C) passed.

D) ignored.

E) None of the above

Q3) The C++ mechanism for exception handling encloses code that might throw an exception in a try block and puts exception handling code in catch blocks attached to the try block.

A)True

B)False

Q4) A program may not contain a "regular" version of a function and a template version of the function at the same time.

A)True

B)False

Page 18

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

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 Standard Template Library (STL) provides a linked list container.

L) provides a linked list container.

A)True

B)False

Q2) If a node is not the first node in a linked list, deleting it may require setting the successor pointer in its predecessor.

A)True

B)False

Q3) Inserting an item into a linked list requires that all the items past the point of the insertion be shifted to make room for the new item.

A)True

B)False

Q4) A ________ is used to step through a linked list and search for data.

A) node

B) pointer

C) NULL value

D) traversal operator

E) None of the above

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 stored on a stack.

A) append

B) add

C) pop

D) push

E) None of the above

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

A) push

B) pop

C) delete

D) remove

E) None of the above

Q3) A practical application of the stack data type is

A) the storage of local variables in a function call.

B) the tracking of the order of entry into and exit from nested loops.

C) the tracking of the order of calls and returns of functions in a program.

D) All of the above

E) None of the above

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

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) 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

Q2) There exists a binary tree with a hundred nodes, but only one leaf.

A)True

B)False

Q3) A node that has no children is a

A) root node.

B) head node.

C) leaf node.

D) pure binary node.

E) None of the above

Q4) In a binary search tree, all nodes to the right of a node hold values greater than the node's value.

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