Foundations of Computer Science Question Bank - 899 Verified Questions

Page 1


Foundations of Computer Science Question

Bank

Course Introduction

This course introduces the fundamental concepts of computer science, providing a comprehensive overview of theoretical and practical principles. Topics include algorithms, data structures, computational complexity, formal languages, automata, and the basics of logic and proof techniques. Through a combination of lectures and hands-on problem-solving, students will gain a solid foundation for further study in computer science, developing analytical skills and understanding the mathematical underpinnings of the discipline.

Recommended Textbook

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

Available Study Resources on Quizplus

18 Chapters

899 Verified Questions

899 Flashcards

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

Chapter 1: An Overview of Computers and Programming Languages

Available Study Resources on Quizplus for this Chatper

50 Verified Questions

50 Flashcards

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

Sample Questions

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

A) entry

B) input

C) output

D) secondary

Answer: B

Q2) The basic commands that a computer performs are ____, and performance of arithmetic and logical operations.

A) input, file, list

B) output, folder, storage

C) input, output, storage

D) storage, directory, log

Answer: C

Q3) Main memory is directly connected to the CPU.

A)True

B)False

Answer: True

Q4) In a C++ program, statements that begin with the symbol # are called ____________________ directives.

Answer: preprocessor

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

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/21709

Sample Questions

Q1) The value of the expression 17 % 7 is ____.

A) 1

B) 2

C) 3

D) 4

Answer: C

Q2) In C++, reserved words are the same as predefined identifiers. A)True

B)False

Answer: False

Q3) ____________________ is the process of planning and creating a program.

Answer: Programming programming

Q4) Suppose that sum is an int variable. The statement sum += 7; is equivalent to the statement sum = sum + 7;

A)True

B)False

Answer: True

Q5) The memory space for a(n) ____________________ data value is 64 bytes. Answer: long long

Page 4

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

Chapter 3: Inputoutput

Available Study Resources on Quizplus for this Chatper

50 Verified Questions

50 Flashcards

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

Sample Questions

Q1) What is the output of the following statements? cout << setfill('*');

Cout << "12345678901234567890" << endl

Cout << setw(5) << "18" << setw(7) << "Happy" << setw(8) << "Sleepy" << endl;

A) 12345678901234567890

***18 Happy Sleepy

B) 12345678901234567890

***18**Happy**Sleepy

C) 12345678901234567890

***18**Happy Sleepy

D) 12345678901234567890

***18**Happy Sleepy**

Answer: B

Q2) Manipulators without parameters are part of the ____ header file. A) iostream

B) iomanip

C) ifstream

D) pmanip

Answer: A

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

5

Chapter 4: Control Structures I Selection

Available Study Resources on Quizplus for this Chatper

50 Verified Questions

50 Flashcards

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

Sample Questions

Q1) The conditional operator ?: takes ____ arguments.

A) two

B) three

C) four

D) five

Q2) Every else must be paired with a(n) ____________________.

Q3) A(n) ____________________ structure does not require the evaluation of a logical expression.

Q4) The operators != and == have the same order of precedence.

A)True

B)False

Q5) A ____________________ operator allows you to make comparisions in a program.

Q6) To develop a program, you can use an informal mixture of C++ and ordinary language, called ____.

A) assert code

B) pseudocode

C) cppcode

D) source code

Q7) The value of the expression 7 + 8 <= 15 is ____________________.

Q8) In C++, the logical operator AND is represented by ____________________. Page 6

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

Page 7

Chapter 5: Control Structures II Repetition

Available Study Resources on Quizplus for this Chatper

50 Verified Questions

50 Flashcards

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

Sample Questions

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

Q2) What is the next Fibonacci number in the following sequence? 1, 1, 2, 3, 5, 8, 13, 21, ...

A) 34

B) 43

C) 56

D) 273

Q3) The control variable in a flag-controlled while loop is a bool variable.

A)True

B)False

Q4) A semicolon at the end of the for statement (just before the body of the loop) is a(n) ____________________ error.

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 ____________________.

Q7) A for loop is typically called a counted or ____________________ for loop.

Page 8

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

Chapter 6: User-Defined Functions

Available Study Resources on Quizplus for this Chatper

50 Verified Questions

50 Flashcards

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

Sample Questions

Q1) The data type of a variable in a return statement must match the function type.

A)True

B)False

Q2) The statement: return 2 * 3 + 1, 1 + 5; returns the value ____.

A) 2

B) 3

C) 6

D) 7

Q3) A variable for which memory is allocated at block entry and deallocated at block exit is called a(n) ____________________ variable.

Q4) Assume the following. static_cast&lt;int&gt;('a') = 97

Static_cast&lt;int&gt;('A') = 65

The output of the statement: Cout << static_cast&lt;int&gt;(tolower('B')) << endl; is ____.

A) 65

B) 67

C) 96

D) 98

Q5) The ____________________ of a function consists of the function name and its formal parameter list.

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

Chapter 7: User-Defined Simple Data Types, Namespaces, and

the String Type

Available Study Resources on Quizplus for this Chatper

50 Verified Questions

50 Flashcards

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

Sample Questions

Q1) Which of the following statements declares the studentGrade variable?

A) enum studentGrade {A, B, C, D, F};

B) enum int {A, B, C, D, F} studentGrade;

C) enum studentGrade {A, B, C, D, F} grades;

D) enum grades {A, B, C, D, F} studentGrade;

Q2) In C++, you can create aliases to a previously defined data type by using the ____ statement.

A) typedef

B) using C) namespace

D) alias

Q3) In C++, ____ is called the scope resolution operator.

A) .

B) \(?\)

C) :

D) ::

Q4) Suppose str = "abcd". After the statement str = str + "ABCD"; the value of str is "____________________".

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

Q5) Suppose str = "abcd"; After the statement str[1] = 'A'; The value of str is "____________________".

Chapter 8: Arrays and Strings

Available Study Resources on Quizplus for this Chatper

50 Verified Questions

50 Flashcards

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

Sample Questions

Q1) In the following declaration, the array gamma has ____________________ components.

int gamma[5][6][10];

Q2) When you pass an array as a parameter, the base address of the actual array is passed to the formal parameter.

A)True

B)False

Q3) Assume you have the following declaration char nameList[100];. Which of the following ranges is valid for the index of the array nameList?

A) 0 through 99

B) 0 through 100

C) 1 through 100

D) 1 through 101

Q4) In a two-dimensional array, the elements are arranged in a table form.

A)True

B)False

Q5) In a(n) ____________________ data type, each data item is a collection of other data items.

Q6) The statement strlen("Marylin Stewart"); returns ____________________.

Page 11

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

Chapter 9: Records Structs

Available Study Resources on Quizplus for this Chatper

50 Verified Questions

50 Flashcards

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

Sample Questions

Q1) A list has two items associated with it: ____.

A) the length and the references

B) the values and the references

C) the indexes and the length

D) the values and the length

Q2) Consider the accompanying struct definition in Figure 1. The statement ____________________ defines alumnus to be a struct variable of type newStudent.

Q3) Which of the following aggregate operations can be executed on array variables?

A) Arithmetic

B) Assignment

C) Function returning a value

D) Parameter passing by reference

Q4) The syntax for accessing a struct member is structVariableName____.

A) .memberName

B) *memberName

C) [memberName]

D) $memberName

Q5) In C++, struct is a(n) ____________________ word.

Q6) Arrays are passed by ____________________ only.

Q7) A(n) ____________________ is a set of elements of the same type.

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

49 Verified Questions

49 Flashcards

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

Sample Questions

Q1) If a member of a class is ____, you cannot access it outside the class.

A) public

B) automatic

C) private

D) static

Q2) To create the object code file for any source code file, the command line option ____________________ is used on the system command line.

Q3) A(n) ____________________ statement is required by any program that uses a header class file, as well as by the implementation file that defines the operations for that class.

Q4) A C++ implementation file has the extension ____________________.

Q5) If the heading of a member function of a class ends with the word const, then the function member cannot modify the private member variables, but it can modify the public member variables.

A)True

B)False

Q6) A(n) ____________________ is a statement specifying the condition(s) that must be true before the function is called.

Q7) Object code is produced from a(n) ____________________.

Page 13

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

Chapter 11: Inheritance and Composition

Available Study Resources on Quizplus for this Chatper

50 Verified Questions

50 Flashcards

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

Sample Questions

Q1) C++ provides ____________________ functions as a means to implement polymorphism in an inheritance hierarchy.

Q2) The private members of a base class can be directly accessed by a derived class.

A)True

B)False

Q3) The ____ members of an object form its internal state.

A) private

B) protected

C) public

D) static

Q4) A derived class can directly access the protected members of the base class.

A)True

B)False

Q5) Inheritance is an example of a(n) ____ relationship.

A) is-a

B) has-a

C) handshaking

D) had-a

Q6) The term ____________________ is used to describe the ability to create new objects from existing objects.

Page 14

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

Chapter 12: Pointers, Classes, Virtual Functions, and

Abstract Classes

Available Study Resources on Quizplus for this Chatper

50 Verified Questions

50 Flashcards

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

Sample Questions

Q1) Consider the following statements: int x;

int &y = x;

The second statement declares y to be a(n) ____________________ of x.

Q2) In C++, ____ is called the address of operator.

A) &

B) *

C) #

D) ->

Q3) The statement int *p; is equivalent to int * p;, which is also equivalent to the statement ____________________.

Q4) Which of the following can be used to initialize a pointer variable?

A) 1

B) NULL

C) "0"

D) '0'

Q5) The statement that declares board to be an array of six pointers wherein each pointer is of type int is: int ____________________;

Q6) The binding of virtual functions occurs at program ____________________ time. Page 15

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

Page 16

Chapter 13: Overloading and Templates

Available Study Resources on Quizplus for this Chatper

50 Verified Questions

50 Flashcards

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

Sample Questions

Q1) To include the operator function operator+ as a nonmember function of the class rectangleType, its prototype in the definition of rectangleType is: ____ rectangleType operator+(const rectangleType&, const rectangleType&);

A) bool

B) int

C) double

D) friend

Q2) Class templates are called ____ types.

A) polymorphic

B) structured

C) member

D) parameterized

Q3) The operator function that overloads the insertion operator, <<, or the extraction operator, >>, for a class must be a(n) ____________________ function of that class.

Q4) A friend function does not have access to the private data members of the class.

A)True

B)False

Q5) Any function that overloads an operator is called a(n) ____________________ function.

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

Chapter 14: Exception Handling

Available Study Resources on Quizplus for this Chatper

50 Verified Questions

50 Flashcards

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

Sample Questions

Q1) Which of the following classes is derived from the class runtime_error?

A) bad_alloc

B) out_of_range

C) overflow_error

D) length_error

Q2) In a sequence of try/catch blocks, the last catch block of that sequence should be

A) catch(...){ }

B) catch(int x){ }

C) catch(str){ }

D) catch(exception){}

Q3) The class ____ is designed to deal with illegal arguments used in a function call.

A) illegal_argument

B) bad_argument

C) invalid_call

D) invalid_argument

Q4) If the operator new cannot allocate memory space, this operator throws a(n) ____________________ exception.

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

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

Chapter 15: Recursion

Available Study Resources on Quizplus for this Chatper

50 Verified Questions

50 Flashcards

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

Sample Questions

Q1) Consider the following definition of the recursive function print. void print(int num) { \(\quad\)if (num > 0) \(\quad\){

\(\quad\)\(\quad\)cout << num << " "; \(\quad\)\(\quad\)print(num - 1); \(\quad\)}

} What is the output of the following statement? Print(4);

Q2) Let x be an integer. We call the ____________________ of x after division by 2 the rightmost bit of x.

Q3) You can use a recursive algorithm to find the largest element in an array. A)True B)False

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

Chapter 16: Searching, Sorting and the Vector Type

Available Study Resources on Quizplus for this Chatper

50 Verified Questions

50 Flashcards

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

Sample Questions

Q1) With the binary search algorithm, ____ key comparison(s) is/are made in the successful case-the last time through the loop.

A) one

B) two

C) n-2

D) n

Q2) If the search item is the 900th item in the list, the sequential search makes ____ key comparisons to determine whether the search item is in the list.

A) 100

B) 900

C) 9000

D) 90,000

Q3) The type vector provides the expression ____________________, which inserts a copy of elem into vecList at the end.

Q4) The type vector provides the function ____________________, which deletes all elements from the object.

Q5) The type vector provides the expression ____________________, which returns the last element of the object.

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

Chapter 17: Linked Lists

Available Study Resources on Quizplus for this Chatper

50 Verified Questions

50 Flashcards

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

Sample Questions

Q1) In a linked list, if a new item is always inserted at the beginning or at the end of the list and the data we read is unsorted, the linked list will be unsorted.

A)True

B)False

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

A) head = NULL; Back = NULL;

B) head = 0;

Back = 0; Count = 0;

C) first = 0; Last = 0; D) first = NULL; Last = NULL; 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 21

Chapter 18: Stacks and Queues

Available Study Resources on Quizplus for this Chatper

50 Verified Questions

50 Flashcards

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

Sample Questions

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

A) 4

B) 14

C) 24

D) 26

Q2) A queue is a First In First Out data structure.

A)True

B)False

Q3) Which of the following is listed in the chapter as a basic operation performed on a queue?

A) push

B) pop

C) isEmptyQueue

D) top

Q4) A stack is a(n) ____ data structure.

A) FIFO

B) FILO

C) LIFO

D) LILO

Q5) An array is a(n) ____________________ access data structure.

Page 22

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

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.
Foundations of Computer Science Question Bank - 899 Verified Questions by Quizplus - Issuu