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.

351.

A function that is called automatically each time an object is created is a(n)

A. constructor
B. contractor
C. builder
D. architect
Answer» B. contractor
352.

The element of an array is

A. the name of the array
B. a member of an array
C. a value assigned to an array
D. All of the above
Answer» C. a value assigned to an array
353.

You _____ write your own container classes

A. must
B. may
C. should not
D. must not
Answer» C. should not
354.

Passing a variable pointer as a constant _____

A. protects the contents pointed to by the pointer from change
B. eliminates the need to name the pointer in the function
C. eliminates the need to give the pointer a type in the function
D. causes a copy of the pointer to be produced in the function
Answer» B. eliminates the need to name the pointer in the function
355.

The most efficient data type for a variable that stores the number 4.6e20 is the _____ data type

A. Character
B. Double
C. Float
D. Long Integer
Answer» D. Long Integer
356.

If you assign a default value to any variable in a function prototype's parameter list, then _____

A. all other parameters in the function prototype must have default values
B. all parameters to the right of that variable must have default values
C. all parameters to the left of that variable must have default values
D. no other parameters in that prototype can have default values
Answer» C. all parameters to the left of that variable must have default values
357.

Assume you want to compare the character stored in the initial variable to the letter a. Which of the following conditions should you use in the if statement? (Be sure the condition will handle a or A.)

A. (initial = 'a' or 'A')
B. (initial == 'a' or 'A')
C. (toupper(initial) = 'A')
D. (toupper(initial) == 'A')
Answer» E.
358.

The functions go in the _____ section of a class definition

A. declaration
B. implementation
C. prototype
D. functioning
Answer» C. prototype
359.

A function's purpose is to print customer data. Which of the following is the best name for this function?

A. pcd(). It's short for "print customer data" and takes few keystrokes
B. Printcustomerdata(). It states everything the function will do
C. printCustomer(). It states the function's purpose and is easy to read
D. lastFunction(). It is the final function called in most programs, and this name identifies the function's timing
Answer» D. lastFunction(). It is the final function called in most programs, and this name identifies the function's timing
360.

The compiler converts your C++ instructions into _____

A. edited code
B. object code
C. source code
D. translated code
Answer» C. source code
361.

A program will have one function prototype for each function defined in the programmer-defined section of the program. (Assume that the programmer-defined section is located below the main function.)

A. 1
B.
C. cin
D. cout
Answer» B.
362.

Errors in a program are called

A. accidents
B. annoyances
C. bugs
D. mistakes
Answer» D. mistakes
363.

Declaring variables is advantageous because it

A. avoids errors from misspelled variable names {b) helps the linker work efficiently
B. simplifies the writing of very short programs
C. All of the above
D. None of the above
Answer» D. None of the above
364.

One drawback to returning an error code from a function is _____

A. functions cannot return error codes
B. error codes must be integers, and some functions can't return an integer
C. a function can return only one value, so it can return only the error code
D. a function that returns an error code will identify all returns as errors
Answer» D. a function that returns an error code will identify all returns as errors
365.

A function that changes the state of the cout object is called a(n) _____

A. member
B. adjuster
C. manipulator
D. operator
Answer» D. operator
366.

If you omit any constructor argument when you instantiate an object, you must use default values

A. for all parameters to the constructor
B. for all parameters to the right of the argument
C. for all parameters to the left of the argument
D. for no other parameters
Answer» C. for all parameters to the left of the argument
367.

You have declared an integer pointer called point You have also declared an integer called number. Which statement is the correct format?

A. point = number;
B. point = *number;
C. point = &number;
D. point = +number;
Answer» D. point = +number;
368.

The standard output stream, which refers to the computer screen, is called

A. cin
B. cout
C. stin
D. stout
Answer» C. stin
369.

Files whose names end in .h are called _____ files

A. handy
B. header
C. helper
D. helping
Answer» C. helper
370.

The program can access the private members of a class

A. directly
B. only through other private members of the class
C. only through other public members of the class
D. None of the above - the program cannot access the private members of a class in any way
Answer» D. None of the above - the program cannot access the private members of a class in any way
371.

To execute a C++ program, you first need to translate the source code into object code. This process is called

A. coding
B. compiling
C. sourcing
D. translating
Answer» C. sourcing
372.

The generic name used for unexpected errors that occur during the execution of a program is

A. infractions
B. exceptions
C. deviations
D. anomalies
Answer» C. deviations
373.

To hide a data member from the program, you must declare the data member in the _____ section of the class

A. concealed
B. confidential
C. hidden
D. private
Answer» E.
374.

Typing the function's name as Main, rather than main, is an example of

A. an entry error
B. a function error
C. a logic error
D. a syntax error
Answer» E.
375.

If you want to override constructor default values for an object you are instantiating, you must also override

A. all other parameters to that constructor
B. all parameters to the left of that value
C. all parameters to the right of that value
D. no other parameters to that constructor
Answer» C. all parameters to the right of that value
376.

A member function uses the correct object when you call it because

A. a copy of the object is passed to the function
B. the address of the object is passed to the function
C. the address of the function is passed to another function
D. the address of the object is returned from the function
Answer» C. the address of the function is passed to another function
377.

The two statements that can be used to change the flow of control are

A. if and switch
B. if and while
C. switch and do-while
D. break and continue
Answer» B. if and while
378.

A major advantage of inheritance is

A. reducing the time it takes to create new objects
B. not having to think about how objects will be used
C. reducing the amount of memory required to execute a progrma
D. enabling people who have not studied programming to create useful applications
Answer» B. not having to think about how objects will be used
379.

Any #include files may contain

A. constants
B. variables
C. functions
D. All of the above
Answer» E.
380.

A base class may also be called a

A. child class
B. subclass
C. derived class
D. parent class
Answer» E.
381.

The most efficient data type for a variable that the number 20000 is the _____ data type

A. Character
B. Double
C. Float
D. Long Integer
Answer» E.
382.

With commercial classes, the function source code is usually________

A. printed on high-quality paper
B. poorly written
C. provided on a disk
D. provided in object form
Answer» E.
383.

The String data type is an extension of the _____ data type

A. Character
B. Double
C. Letter
D. Long
Answer» B. Double
384.

When the function int someFunction(char c) throw( ) is executed, _____

A. it can throw anything
B. it may throw an integer
C. it may throw a character
D. it may not throw anything
Answer» E.
385.

The generic type in a template function

A. must be T
B. can be T
C. cannot be T for functions you create, but may be for C++'s built-in functions
D. cannot be T
Answer» C. cannot be T for functions you create, but may be for C++'s built-in functions
386.

The set of instructions for how to tie a bow is an example of the _____ structure

A. control
B. repetition
C. selection
D. sequence
Answer» E.
387.

The logical NOT operator represented by is a

A. unary operator
B. binary operator
C. ternary operator
D. octal operator
Answer» B. binary operator
388.

To send output to a file, you need to include the _____ header file in your program

A. file.h
B. fstream.h
C. iomanip.h
D. iostream.h
Answer» C. iomanip.h
389.

C++ allows you to define the same functions more than once in the same program _____

A. if the definitions are identical
B. if the definitions are included in two separate #include files
C. if the definitions are located in a single #include file that is included more than once
D. C++ does not allow you to define the same functions more than once in the same program
Answer» E.
390.

A data member holds a 1 or 0 depending on whether taxes have been paid. The best identifier for this member is _____

A. taxes
B. paidTaxes
C. taxesArePaid
D. code
Answer» C. taxesArePaid
391.

The return type you code for all constructors is _____

A. void
B. the class type
C. the same type as the first data member defined in the class
D. no type
Answer» E.
392.

A class hierarchy

A. describes "is a kind of" relationships
B. describes "has a" relationships
C. shows the same relationships as an organization chart
D. shows the same relationships as a family tree
Answer» B. describes "has a" relationships
393.

The statement double val[15]={44.123456};

A. assigns the value 44.123456 to all members of the array val
B. assigns the value 44.123456 to val[0] and 0 to the rest of the members
C. gives an error message
D. assigns the value 44.12345 to val[1] and val[5]
Answer» C. gives an error message
394.

The expression c = i++ causes

A. the value of i assigned to c and then i incremented by 1
B. i to be incremented by 1 and then the value of i assigned to c
C. value of i assigned to c
D. i to be incremented by 1
Answer» B. i to be incremented by 1 and then the value of i assigned to c
395.

A function that returns no values to the program that calls it is _____

A. not allowed in C++
B. type void
C. type empty
D. type barren
Answer» C. type empty
396.

The first element in a string is

A. the name of the string
B. the first character in the string
C. the length of the string
D. the name of the array holding the string
Answer» C. the length of the string
397.

You can use the C++ _____ function to assign a value to a String variable

A. assign
B. copy
C. string
D. strcopy
Answer» E.
398.

Which of the following statements uses the computer's clock to initialize the random number generator?

A. srand(time);
B. srand(time(NULL));
C. time(srand);
D. time(srand(NULL));
Answer» C. time(srand);
399.

A program that predicts the exact sequence in which events will take place is said to be ________

A. compiled
B. interpreted
C. procedural
D. object-oriented
Answer» D. object-oriented
400.

An address is a _____ , while a pointer is a _____

A. array, variable
B. constant, variable
C. variable, position
D. variable, location
Answer» E.