Computer Science I Midterm Exam - 751 Verified Questions

Page 1


Computer Science I

Midterm Exam

Course Introduction

Computer Science I is an introductory course that explores the fundamental concepts of computer science and programming. Students will develop problem-solving skills by learning how to design, write, and test algorithms and programs using a high-level programming language such as Python or Java. The course covers core topics including data types, control structures, functions, input/output, and basic data structures like arrays and lists. Emphasis is placed on logical thinking, debugging, and developing programs that address real-world problems, laying a strong foundation for further study in computer science.

Recommended Textbook

C++ Programming From Problem Analysis to Program Design 8th Edition by D. S. Malik

Available Study Resources on Quizplus

18 Chapters

751 Verified Questions

751 Flashcards

Source URL: https://quizplus.com/study-set/3129 Page 2

Chapter 1: An Overview of Computers and Programming Languages

Available Study Resources on Quizplus for this Chatper

40 Verified Questions

40 Flashcards

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

Sample Questions

Q1) ____________________ languages include FORTRAN, COBOL, Pascal, C, C++, Java, and Python.

Answer: High-level

high-level

High level

high level

Q2) A program called a(n) ____ translates instructions written in high-level languages into machine code.

A) assembler

B) decoder

C) compiler

D) linker

Answer: C

Q3) The devices that feed data and programs into computers are called ____ devices.

A) entry

B) input

C) output

D) secondary

Answer: B

Page 3

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

Chapter 2: Basic Elements of C++

Available Study Resources on Quizplus for this Chatper

50 Verified Questions

50 Flashcards

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

Sample Questions

Q1) An example of a floating point data type is ____.

A) int

B) char

C) double

D) short Answer: C

Q2) Suppose we declare a variable sum as an int. The statement "sum += 7;" is equivalent to the statement "sum = sum + 7;".

A)True

B)False

Answer: True

Q3) The declaration int a, b, c; is equivalent to which of the following?

A) inta , b, c;

B) int a,b,c;

C) int abc;

D) int a b c;

Answer: B

Q4) The maximum number of significant digits is called the ____________________.

Answer: precision

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

Chapter 3: Inputoutput

Available Study Resources on Quizplus for this Chatper

40 Verified Questions

40 Flashcards

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

Sample Questions

Q1) Entering a char value into an int variable causes serious errors, called input failure.

A)True

B)False

Answer: True

Q2) The function ____________________ returns the next character in the input stream; it does not remove the character from the input stream.

Answer: peek

Q3) ____ is a parameterized stream manipulator.

A) endl

B) fixed

C) scientific

D) setfill

Answer: D

Q4) In C++, the dot is an operator called the ____ operator.

A) dot access

B) member access

C) data access

D) member

Answer: B

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

Chapter 4: Control Structures I Selection

Available Study Resources on Quizplus for this Chatper

40 Verified Questions

40 Flashcards

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

Sample Questions

Q1) Which of the following will cause a logical error if you are attempting to compare x to 5?

A) if (x == 5)

B) if (x = 5)

C) if (x <= 5)

D) if (x >= 5)

Q2) Suppose x is 5 and y is 7. Choose the value of the following expression: (x != 7) && (x <= y)

A) false

B) true

C) 0

D) null

Q3) Which of the following expressions correctly determines that x is greater than 10 and less than 20?

A) 10 < x < 20

B) (10 < x < 20)

C) 10 < x && x < 20

D) 10 < x || x < 20

Q4) Putting ____________________ in front of a logical expression reverses the value of that logical expression.

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

Chapter 5: Control Structures II Repetition

Available Study Resources on Quizplus for this Chatper

40 Verified Questions

40 Flashcards

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

Sample Questions

Q1) A loop ____________________ is a set of statements that remains true each time the loop body is executed.

Q2) The control statements in the for loop include the initial statement, loop condition, and update statement.

A)True

B)False

Q3) In a counter-controlled while loop, the loop control variable must be initialized before the loop.

A)True

B)False

Q4) The number of iterations of a counter-controlled loop is known in advance.

A)True

B)False

Q5) Which of the following is a repetition structure in C++?

A) if

B) switch

C) while...do

D) do...while

Q6) The function eof is a member of the data type ____________________.

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

Chapter 6: User-Defined Function

Available Study Resources on Quizplus for this Chatper

41 Verified Questions

41 Flashcards

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

Sample Questions

Q1) If the formal parameter list of a function is empty, the parentheses after the function name are not needed.

A)True

B)False

Q2) If a function needs to return more than one value, as a rule of good programming style, you should change it to a(n) ____________________ function and use the appropriate reference parameters to return the values.

Q3) To use the predefined function tolower, the program must include the header file

A) &lt;cctype&gt;

B) &lt;iostream&gt;

C) &lt;cmath&gt;

D) &lt;cstdlib&gt;

Q4) Which of the following function prototypes is valid?

A) int funcExp(int x, float v);

B) funcExp(int x, float v){};

C) funcExp(void);

D) int funcExp(x);

Q5) A function ____________________ is a function that is not fully coded.

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

Chapter 7: Namespaces, the Class String, and

User-Defined Simple Data Types

Available Study Resources on Quizplus for this Chatper

40 Verified Questions

40 Flashcards

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

Sample Questions

Q1) The values in the domain of an enumeration type are called

Q2) The data type string has a named constant, ____, associated with it.

A) string::size

B) string::size_type

C) string::pos

D) string::npos

Q3) The length of the string "Hello There. " is ____.

A) 11

B) 12

C) 13

D) 14

Q4) The string expression strVar.____________________ inserts all the characters of str at index pos into strVar.

Q5) The ____ function is used to interchange the contents of two string variables.

A) iterator

B) traverse

C) swap

D) change

Q6) In ANSI/ISO Standard C++, the ____________________ mechanism was designed to solve the problem of overlapping global identifiers. Page 9

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

Page 10

Chapter 8: Arrays

Available Study Resources on Quizplus for this Chatper

40 Verified Questions

40 Flashcards

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

Sample Questions

Q1) A collection of a fixed number of elements (called components) arranged in n dimensions (n >= 1) is called a(n) ____.

A) matrix

B) vector

C) n-dimensional array

D) parallel array

Q2) Arrays can be passed as parameters to a function by value, but it is faster to pass them by reference.

A)True

B)False

Q3) Which of the following correctly declares name to be a character array and stores "William" in it?

A) char name[6] = "William";

B) char name[7] = "William";

C) char name[8] = "William";

D) char name[8] = 'William';

Q4) The word ____________________ is used before the array declaration in a function heading to prevent the function from modifying the array.

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

11

Chapter 9: Records Structs

Available Study Resources on Quizplus for this Chatper

40 Verified Questions

40 Flashcards

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

Sample Questions

Q1) An array name and index are separated using ____.

A) curly brackets

B) square brackets

C) a dot

D) a comma

Q2) The following statement defines a struct houseType with a total of ____________________ member(s).

struct houseType

{ string style; int numOfBedrooms; int numOfBathrooms; int numOfCarsGarage; int yearBuilt; };

Q3) Typically, in a program, a struct is defined ____ in the program.

A) in the main function

B) before the definitions of all the functions

C) after the definitions of all the functions

D) in any function

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

Chapter 10: Classes and Data Abstraction

Available Study Resources on Quizplus for this Chatper

43 Verified Questions

43 Flashcards

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

Sample Questions

Q1) In C++, the ____ is called the member access operator.

A) .

B) ,

C) ::

D) #

Q2) If a class object is passed by ____________________, the contents of the member variables of the actual parameter are copied into the corresponding member variables of the formal parameter.

Q3) A(n) ____________________ function of a class changes the values of the member variable(s) of the class.

Q4) Consider the accompanying class definition, and the declaration: rectangleType bigRect;

Which of the following statements is correct?

A) rectangleType.print();

B) rectangleType::print();

C) bigRect.print();

D) bigRect::print();

Q5) The header file is also known as the ____________________.

Q6) Non-static member variables of a class are called the ____________________ variables of the class.

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

Chapter 11: Inheritance and Composition

Available Study Resources on Quizplus for this Chatper

41 Verified Questions

41 Flashcards

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

Sample Questions

Q1) The constructors of a derived class can (directly) initialize only the (public data) members inherited from the base class of the derived class.

A)True

B)False

Q2) If the corresponding functions in the base class and the derived class have the same name but different sets of parameters, then this function is ____ in the derived class.

A) reused

B) redefined

C) overloaded

D) overridden

Q3) If inheritance is private, all members of the base class, including private members, become private members of the derived class.

A)True

B)False

Q4) In multiple inheritance, the derived class has more than one base class.

A)True

B)False

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

Page 14

Chapter 12: Pointers, Classes, Virtual Functions, and

Abstract Classes

Available Study Resources on Quizplus for this Chatper

43 Verified Questions

43 Flashcards

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

Sample Questions

Q1) Which of the following would be appropriate syntax for the heading of a copy constructor for a class called rulerType?

A) rulerType(int inches, int centimeters)

B) rulerType()

C) rulerType(const rulerType& myRuler)

D) copy rulerType(int inches, int centimeters)

Q2) The dereferencing operator is also known as the indirection operator and refers to the object to which its operand points.

A)True

B)False

Q3) A class ____ automatically executes whenever a class object goes out of scope. A) constructor

B) destructor

C) pointer

D) exception

Q4) The ____________________ of a base class automatically makes the destructor of a derived class virtual.

Q5) The copy constructor automatically executes when, as a parameter, an object is passed by ____________________.

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

Chapter 13: Overloading and Templates

Available Study Resources on Quizplus for this Chatper

41 Verified Questions

41 Flashcards

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

Sample Questions

Q1) Most operator functions can either be member functions or nonmember functions of a class.

A)True

B)False

Q2) In C++, operator is a reserved word.

A)True

B)False

Q3) When writing the definition of a friend function, the name of the class and the scope resolution operator precede the name of the friend function in the function heading.

A)True

B)False

Q4) The name of the function to overload the operator <= is ____.

A) overload<=

B) <=new

C) operator<=

D) <=operator

Q5) A(n) ____________________ constructor converts its argument to an object of the constructor's class.

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

Chapter 14: Exception Handling

Available Study Resources on Quizplus for this Chatper

42 Verified Questions

42 Flashcards

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

Sample Questions

Q1) One of the typical ways of dealing with exceptions is to use an if statement.

A)True

B)False

Q2) The class ____ is the base of the classes designed to handle exceptions.

A) class

B) exception

C) logic_error

D) runtime_error

Q3) The class ____________________ deals with the string subscript out of range error.

Q4) The function ____ returns a string containing an appropriate message.

A) where

B) what

C) when

D) log

Q5) An exception is an occurrence of an undesirable situation that can be detected during program compilation.

A)True

B)False

Q6) In C++, throw is a(n) ____________________ word.

Page 17

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

Chapter 15: Recursion

Available Study Resources on Quizplus for this Chatper

41 Verified Questions

41 Flashcards

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

Sample Questions

Q1) If you execute an infinite recursive function on a computer, the function executes until the system runs out of ____________________.

Q2) Which of the following function headings can be used for a recursive definition of a function to calculate the nth Fibonacci number?

A) void rFibNum(int a, int b)

B) bool rFibNum(int a, int b)

C) bool rFibNum(int a, int b, int n)

D) int rFibNum(int a, int b, int n)

Q3) The recursive algorithm must have one or more base cases, and the general solution must eventually be reduced to a(n) ____________________.

Q4) In a recursive function, the base case stops the recursion.

A)True B)False

Q5) The ____________________ Fibonacci number in a sequence is the sum of the second and third Fibonacci numbers.

Q6) In the Tower of Hanoi problem, if needle 1 contains three disks, then the number of moves required to move all three disks from needle 1 to needle 3 is

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

Chapter 16: Searching and Sorting

Available Study Resources on Quizplus for this Chatper

46 Verified Questions

46 Flashcards

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

Sample Questions

Q1) Consider the following list. int list[] = {4, 8, 19, 25, 34, 39, 45, 48, 66, 75, 89, 95}

When performing a binary search for 75, after the first comparison, the search is restricted to ____.

A) list[0]...list[6]

B) list[0]...list[7]

C) list[5]...list[11]

D) list[6]...list[11]

Q2) In order to apply a(n) ____________________ search, the list must be sorted.

Q3) The type vector provides the expression ____________________, which returns the maximum number of elements that can be inserted into the object vecList.

Q4) For a list size of 1000, on average, the sequential search makes about ____________________ key comparisons.

Q5) Assume that n = 1000. To sort the list, bubble sort makes about ____ item assignments.

A) 10,000

B) 100,000

C) 250,000

D) 500,000

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

Chapter 17: Linked Lists

Available Study Resources on Quizplus for this Chatper

41 Verified Questions

41 Flashcards

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

Sample Questions

Q1) Consider the statements above. The list is empty if the pointer first is ____.

A) nullptr

B) 0

C) last

D) next

Q2) Which of the following correctly initializes a doubly linked list in the default constructor?

A) head = nullptr;

Back = nullptr;

B) head = 0;

Back = 0;

Count = 0;

C) first = 0;

Last = 0;

D) first = nullptr;

Last = nullptr;

Count = 0;

Q3) A linked list is a random access data structure.

A)True

B)False

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

Chapter 18: Stacks and Queues

Available Study Resources on Quizplus for this Chatper

42 Verified Questions

42 Flashcards

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

Sample Questions

Q1) The elements at the ____________________ of the stack have been in the stack the longest.

Q2) To describe a queuing system, we use the term ____ for the object receiving the service.

A) receiver

B) server

C) customer

D) provider

Q3) The postfix expression 2 4 6 * + 15 - 21 7 / + = evaluates to ____.

A) 4

B) 14

C) 24

D) 26

Q4) The postfix expression 14 2 5 + = will generate an error, because ____.

A) it contains an illegal operator

B) it does not have enough operands

C) it has too many operators

D) there will be too many elements in the stack when the equal sign is encountered

Q5) In ____________________ notation, operators are written after the operands.

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.
Computer Science I Midterm Exam - 751 Verified Questions by Quizplus - Issuu