Explore topic-wise MCQs in Computer Science.

This section includes 542 Mcqs, each offering curated multiple-choice questions to sharpen your Computer Science knowledge and support exam preparation. Choose a topic below to get started.

401.

When two types are used in a function template and one is labeled T, the other

A. must also be named T
B. must be named U
C. can be any legal C++ identfier
D. it is illegal to have two types
Answer» B. must be named U
402.

In C++, the address operator is the following symbol _____

A. >>
B. &
C. *
D. !
Answer» C. *
403.

An array name is a _____

A. subscript
B. formal parameter
C. memory address
D. prototype
Answer» D. prototype
404.

Local variables _____

A. are created outside a block
B. are known only to that block
C. continue to exist when their block ends
D. are illegal in C++
Answer» C. continue to exist when their block ends
405.

Variables that are known only to the function in which they are declared are called _____ variables

A. global
B. local
C. main
D. separate
Answer» C. main
406.

Functions that returns information about an object's state can be classified as ________

A. inspector functions
B. mutator functions
C. auxiliary functions
D. manager functions
Answer» B. mutator functions
407.

To enter a comment in a C++ program, you begin the comment with _____

A. **
B. &&
C. \\
D. @
Answer» E.
408.

Which of the following is the insertion operator?

A. >>
B. <<
C. //
D. /*
Answer» C. //
409.

The _____ function returns the uppercase equivalent of a character

A. caseupper
B. charupper
C. toupper
D. uCase
Answer» D. uCase
410.

A fundamental type such as int or double is a _____

A. programmer-defined type
B. complex type
C. nonscalar type
D. scalar type
Answer» E.
411.

You define a structure type globally because _____

A. you save many lines of code by not rewriting an identical structure definition in each function that uses it
B. you will never change its definition
C. it is required in C++
D. All of the above
Answer» B. you will never change its definition
412.

When the function char someFunction(int x) is executed,

A. it will throw nothing
B. it will throw an integer
C. it will throw a character
D. it may or may not throw anything
Answer» E.
413.

The prototype for a derived class constructor may include arguments for

A. data members of the derived class
B. data members of the base class
C. both (a) and (b)
D. neither (a) nor (b)
Answer» D. neither (a) nor (b)
414.

The name of a function ends with

A. double quotes
B. single quotes
C. parenthesis
D. #
Answer» D. #
415.

To include the double quotes as part of the control string we use the symbol

A. %"
B. ""
C. \"
D. #
Answer» D. #
416.

The 'break' statement is used to exist from

A. a do loop
B. a for loop
C. a switch statement
D. All of the above
Answer» E.
417.

When you define an object that is a member of a class, such as Student Abby; _____

A. a block of memory is set aside and all data members are assigned valid values
B. a block of memory is set aside
C. no memory is set aside until values are defined
D. no memory is set aside, but valid values are assigned to data members
Answer» C. no memory is set aside until values are defined
418.

The step-by-step instructions that solve a problem are called _____

A. an algorithm
B. a list
C. a plan
D. a sequential structure
Answer» B. a list
419.

The weakest form of cohesion is

A. coincidental
B. functional
C. logical
D. communicational
Answer» B. functional
420.

A(n) _____ is a numeric variable used for counting something

A. accumulator
B. adder
C. constant
D. counter
Answer» E.
421.

Header files often have the file extension _____

A. .H
B. .HE
C. .HEA
D. .HEAD
Answer» B. .HE
422.

The keyword used to define a structure is _____

A. stru
B. stt
C. struct
D. structure
Answer» D. structure
423.

A function can

A. return a value
B. perform a task
C. change value of actual arguments in call by reference
D. a, b, c above are all true
Answer» E.
424.

The 'continue' statement is used to

A. permit two different expressions to appear in situations where only one expression would ordinarily be used
B. terminate loops or to exit from a switch
C. alter the normal sequence of program execution by transferring control to some other part of the program
D. All of the above
Answer» E.
425.

The rules of a programming language are called its _____

A. code
B. guidelines
C. procedures
D. regulations
Answer» E.
426.

If p and q are assigned the values 2 and 3 respectively then the statement p = q++

A. gives an error message
B. assigns a value 4 to p
C. assigns a value 3 to p
D. assigns a value 5 to p
Answer» D. assigns a value 5 to p
427.

Variables declared outside a block are called _____

A. global
B. universal
C. stellar
D. external
Answer» B. universal
428.

When all of the operations in a function contribute to the performance of only one task, a function has

A. singular cohesion
B. tight cohesion
C. functional cohesion
D. sequential cohesion
Answer» D. sequential cohesion
429.

The instruction "If it's raining outside, then take an umbrella to work" is an example of the _____ structure

A. control
B. repetition
C. selection
D. sequence
Answer» D. sequence
430.

A blueprint for creating an object in C++ is called _____

A. a class
B. an instance
C. a map
D. a pattern
Answer» B. an instance
431.

The newline character is always included between

A. pair of parentheses
B. pair of curly braces
C. control string
D. &
Answer» D. &
432.

The get() function returns _____

A. a character
B. void
C. a reference to the object that invoked it
D. a copy of the object that invoked it
Answer» D. a copy of the object that invoked it
433.

Which of the following tells C++ to display numbers with two decimal places?

A. setdecimal(2)
B. setiosflags(2)
C. setiosflags(2.00)
D. setprecision(2)
Answer» E.
434.

Which of the following statements allows the user to enter data at the keyboard?

A. cin << currentPay;
B. cin >> currentPay;
C. cout << currentPay;
D. cout >> currentPay;
Answer» C. cout << currentPay;
435.

The number 125.35 is a _____

A. character literal constant
B. numeric literal constant
C. string literal constant
D. variable
Answer» C. string literal constant
436.

When a break statement is used in a loop, the control skips the rest of the statements in the loop after it and jumps

A. to the last lines in the program
B. to the next statement written after the body of the loop
C. to the first statement in the body of the loop
D. All. of the above
Answer» C. to the first statement in the body of the loop
437.

When using the standard files that come with the C++ compiler, you should surround the header file name with _____

A. square brackets
B. angle brackets
C. parentheses
D. quotes
Answer» C. parentheses
438.

Overloaded functions are required to

A. have the same return type
B. have the same number of parameters
C. perform the same basic functions
D. None of the above
Answer» E.
439.

Which of the following formulas can be used to generate random integers between 1 and 10?

A. 1 + rand() % (10 - 1 + 1)
B. 1 + (10 - 1 + 1) % rand()
C. 10 + rand() % (10 - 1 + 1)
D. 10 + rand() % (10 + 1)
Answer» B. 1 + (10 - 1 + 1) % rand()
440.

The items listed in the function header are called _____

A. actual arguments
B. formal parameters
C. passed parameters
D. sent arguments
Answer» C. passed parameters
441.

You add the desired type to a specific template class instantiation by placing the type's name ______

A. between angle brackets
B. in parentheses
C. on a line by itself
D. immediately prior to the class name
Answer» B. in parentheses
442.

Redirection redirects

A. a stream from a file to the screen
B. a file from a device to a stream
C. a device from the screen to a file
D. the screen from a device to a stream
Answer» B. a file from a device to a stream
443.

The best-written classes have

A. all functions private
B. all data public
C. no functions
D. None of the above
Answer» E.
444.

Which of the following declares and initializes an Integer variable named numltems?

A. int numltems = 0;
B. int numltems = '0';
C. integer numltems = 0;
D. numltems int = 0;
Answer» B. int numltems = '0';
445.

The delete operator returns ______ to the operating system

A. memory that is no longer needed
B. void
C. recycle bin
D. None of the above
Answer» B. void
446.

To use the this pointer with a member function, you _____

A. declare this as static
B. declare this as global
C. define this as equal to the address of the appropriate object
D. do nothing; it is automatically supplied for you
Answer» E.
447.

Which of the following control structures is used in every program?

A. repetition
B. selection
C. sequence
D. switching
Answer» D. switching
448.

Which of the following calls a function named displayName, passing it no actual arguments?

A. call displayName;
B. call displayName ();
C. displayName;
D. displayName();
Answer» E.
449.

If a class object is thrown with a throw statement, then a subsequent catch block has a usable match if the type of the catch argument is_________

A. a parent class of the thrown class
B. a child class of the thrown class
C. either (a) or (b)
D. neither (a) nor (b)
Answer» B. a child class of the thrown class
450.

Evaluate the following expression: 7 >=3 + 4 || 6<4 && 2<5

A. 1
B.
C. ios
D. out
Answer» B.