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.

501.

The word case used in the switch statement represents a

A. function in the C++ language
B. data type in the C++ language
C. keyword in the C++ language
D. global variable in the C++ language
Answer» D. global variable in the C++ language
502.

Which of the following can be used to declare the main function?

A. void main
B. void Main()
C. void main()
D. main
Answer» D. main
503.

What does C++ append to the end of a string literal constant?

A. a space
B. a number sign (#)
C. an asterisk (*)
D. a null character
Answer» E.
504.

The function that takes arguments to set the bits of count is _____

A. setf()
B. bitsef()
C. ios()
D. flag()
Answer» B. bitsef()
505.

Library header files usually contain

A. complete functions
B. parts of functions
C. function prototypes for functions stored in other files
D. function bodies, but not function headers
Answer» D. function bodies, but not function headers
506.

When a child class function is called, the compiler looks first for a matching function name in the _____

A. class of the object using the function name
B. immediate ancestor class
C. base class
D. descendant class
Answer» B. immediate ancestor class
507.

A C++ program contains a function with the header int function(double d, char c). Which of the following function headers could be used within the same program?

A. char function(double d, char c)
B. int function(int d, char c)
C. both (a) and (b)
D. neither (a) nor (b)
Answer» C. both (a) and (b)
508.

Simple routines that programmers use as place holders while a system is being tested are called _____

A. stubs
B. stumps
C. holders
D. templates
Answer» B. stumps
509.

The outline or the definition of a function is called its

A. beta test
B. forerunner
C. outline
D. prototype
Answer» E.
510.

Which of the following statements opens a file named temp.dat for output?

A. outFile.open("temp .dat");
B. fileOut.output("temp .dat");
C. openFile.out("temp .dat");
D. fileOpen.out("temp .dat");
Answer» B. fileOut.output("temp .dat");
511.

A function that is called automatically each time an object is destroyed is a

A. constructor
B. destructor
C. destroyer
D. terminator
Answer» C. destroyer
512.

You mark the beginning of a function's block of code with the _____

A. /
B. *
C. {
D. }
Answer» D. }
513.

Which of the following is a valid condition for an if statement? (The condition should be both syntactically and logically valid.)

A. (age) > 65
B. (age > 0 and < 10)
C. (sales > 500 && < 800)
D. (sales > 100 && sales <= 1000)
Answer» E.
514.

A constructor always has

A. communicational cohesion
B. temporal cohesion
C. logical cohesion
D. no cohesion
Answer» C. logical cohesion
515.

The type to be used in an instantiation of a class template follows ________

A. the generic class name
B. the keyword template
C. the keyword class
D. the template definition
Answer» B. the keyword template
516.

A widget is to the blueprint for a widget as an object is to

A. a member function
B. a class
C. an operator
D. a data item
Answer» C. an operator
517.

To use either an input or output file, the program must include the _____ header file

A. filestream.h
B. fstream.h
C. instream.h
D. inoutstream.h
Answer» C. instream.h
518.

You construct a class in two sections, known as the _____

A. header and body
B. type and parameters
C. declaration and implementation
D. pointer and variable
Answer» D. pointer and variable
519.

The last statement in a function is often a(n) _____

A. return
B. goodbye
C. finish
D. endfunction
Answer» B. goodbye
520.

A default catch block catches

A. all thrown objects
B. no thrown objects
C. any thrown object that has not been caught by an earlier catch block
D. all thrown objects that have been caught by an earlier catch block
Answer» D. all thrown objects that have been caught by an earlier catch block
521.

The main difference in operation between an 'if statement and a 'while' statement is

A. the 'while' loop body is executed
B. the body of the 'while' statement may be executed many times, the body of the 'if statements only once
C. the conditional expression following the keyboard is evaluated differently
D. All of the above
Answer» C. the conditional expression following the keyboard is evaluated differently
522.

To be called object-oriented, a programming language must allow

A. functions that return only a single value
B. #include files
C. inheritance
D. All of the above
Answer» D. All of the above
523.

If no constructors can specified for a derived class, objects of the derived class will use the constructors in the base class

A. 1
B.
C. a character
D. void
Answer» B.
524.

Which of the following is(are) invalid string constant(s)?

A. '7.15 pm'
B. "i like e"
C. "7.3el2"
D. "1234el2"
Answer» B. "i like e"
525.

Format flags may be combined using

A. the bitwise OR operator (|)
B. the logical OR operator (||)
C. the bitwise AND operator (&)
D. the logical AND operator (&&)
Answer» B. the logical OR operator (||)
526.

Which of the following assigns the number 5 to the area variable?

A. area 1 = 5
B. area = 5
C. area == 5
D. area --> 5
Answer» C. area == 5
527.

The comma operator (,) is primarily used in conjunction with

A. 'for' statement
B. 'if-else' statement
C. 'do-while' statement
D. All of the above
Answer» B. 'if-else' statement
528.

When the compiler cannot differentiate between two overloaded constructors, they are called

A. overloaded
B. destructed
C. ambiguous
D. dubious
Answer» D. dubious
529.

When you omit parameters from a function call, values can be provided by

A. formal parameters
B. reference parameters
C. overloaded parameters
D. default parameters
Answer» E.
530.

The best form of coupling is _____

A. complete
B. tight
C. loose
D. free
Answer» D. free
531.

Programmer-defined functions can be

A. value-returning functions only
B. void functions only
C. either value-returning or void functions
D. 1
Answer» D. 1
532.

A function whose purpose is to send messages to other functions is known as a _____

A. dispatcher
B. courier
C. messenger
D. sender
Answer» B. courier
533.

You typically initialize a String variable to _____

A. an asterisk
B. a space enclosed in single quotes
C. the number 0
D. a zero-length string
Answer» E.
534.

To expose a data member to the program, you must declare the data member in the _____ section of the class

A. common
B. exposed
C. public
D. unrestricted
Answer» D. unrestricted
535.

If you create an instantiation of a class template with an int, and then create a second instantiation with a double, then

A. you must precede each function call with the word int or double
B. once a function is used as one type, it becomes unavailable for use with the other type
C. there is no difference in the procedure to call a member function
D. you cannot perform this operation in C++
Answer» B. once a function is used as one type, it becomes unavailable for use with the other type
536.

The use of the break statement in a switch statement is

A. optional
B. compulsory
C. not allowed. It gives an error message
D. to check an error
Answer» B. compulsory
537.

Which of the following are valid characters for a numeric literal constant?

A. a decimal point
B. the letter e
C. a minus sign
D. a plus sign
Answer» E.
538.

Variables that are declared in a block are known as _____ variables to that block

A. confined
B. local
C. global
D. immediate
Answer» C. global
539.

The #ifndef directive tests to see whether ________

A. a class has been defined
B. a variable has been given a value
C. a class has no variable definitions
D. any objects of the class have been instantiated
Answer» B. a variable has been given a value
540.

Adding a derived class to a base class requires fundamental changes to the base class

A. 1
B.
Answer» C.
541.

Sending a copy of data to a program module is called _______

A. passing a value
B. making a reference
C. recursion
D. setting a condition
Answer» B. making a reference
542.

You can use C++ as a procedural, as well as an object-oriented, language

A. 1
B.
C. all thrown objects
D. no thrown objects
Answer» B.