C++ MCQ Book

Download as pdf or txt
Download as pdf or txt
You are on page 1of 50

VELOCIS EDUCATION C ++ MCQ MASTERY GUIDE

C++ MCQ
Q1: Who invented C++?
A) Dennis Ritchie
B) Ken Thompson
C) Brian Kernighan
D) Bjarne Stroustrup
Answer: Bjarne Stroustrup

Q2: What is C++?


A) C++ is an object oriented programming language
B) C++ is a procedural programming language
C) c++ supports both procedural and object oriented programming language
D) C++ is a functional programming language
Answer: c++ supports both procedural and object oriented programming language

Q3: Which of the following is the correct syntax of including a user defined header files in C++?
A) #include [userdefined]
B) #include “userdefined”
C) #include <userdefined.h>
D) #include <userdefined>
Answer: #include “userdefined”

Q4: Which of the following user-defined header file extension used in c++?
A) hg
B) cpp
C) h
D) hf
Answer: h

Q5: Which of the following is a correct identifier in C++?


A) VAR_1234
B) $var_name
C) 7VARNAME
D) 7var_name
Answer: VAR_1234

Q6: Which of the following is not a type of Constructor in C++?


A) Default constructor
B) Parameterized constructor
C) Copy constructor
D) Friend constructor
Answer: Friend constructor

Q7: Which of the following approach is used by C++?

1|P ag e
VELOCIS EDUCATION C ++ MCQ MASTERY GUIDE
A) Left-right
B) Right-left
C) Bottom-up
D) Top-down
Answer: Bottom-up

Q8: Which of the following type is provided by C++ but not C?


A) double
B) float
C) int
D) bool
Answer: bool

Q9: By default, all the files in C++ are opened in _________ mode.
A) Binary
B) VTC
C) Text
D) ISCII
Answer: Text

Q10: Which of the following correctly declares an array in C++?


A) array{10};
B) array array[10];
C) int array;
D) int array[10];
Answer: int array[10];

Q11: What is the size of wchar_t in C++?


A) Based on the number of bits in the system
B) 2 or 4
C) 4
D) 2
Answer: Based on the number of bits in the system

Q12: What is the use of the indentation in c++?


A) r distinguishes between comments and inner data
B) distinguishes between comments and outer data
C) distinguishes between comments and code
D) r distinguishes between comments and outer data
Answer: distinguishes between comments and code

Q13: Which is more effective while calling the C++ functions?


A) call by object
B) call by pointer
C) call by value

2|P ag e
VELOCIS EDUCATION C ++ MCQ MASTERY GUIDE
D) call by reference
Answer: call by reference

Q14: Which of the following is used to terminate the function declaration in C++?
A) ;
B) ]
C) )
D) :
Answer: ;

Q15: Which keyword is used to define the macros in c++?


A) #macro
B) #define
C) macro
D) define
Answer: #define

Q16: The C++ code which causes abnormal termination/behaviour of a program should be written
under _________ block.
A) catch
B) throw
C) try
D) finally
Answer: try

Q17: What is Inheritance in C++?


A) Deriving new classes from existing classes
B) Overloading of classes
C) Classes with same names
D) Wrapping of data into a single class
Answer: Deriving new classes from existing classes

Q18: Which of the following symbol is used to declare the preprocessor directives in C++?
A) $
B) ^
C) #
D) *
Answer: #

Q19: What is meant by a polymorphism in C++?


A) class having only single form
B) class having four forms
C) class having many forms
D) class having two forms
Answer: class having many forms

3|P ag e
VELOCIS EDUCATION C ++ MCQ MASTERY GUIDE
Q20: Pick the incorrect statement about inline functions in C++?
A) Saves overhead of a return call from a function
B) They are generally very large and complicated function
C) These functions are inserted/substituted at the point of call
D) They reduce function call overheads
Answer: They are generally very large and complicated function

Q21: Which concept allows you to reuse the written code in C++?
A) Inheritance
B) Polymorphism
C) Abstraction
D) Encapsulation
Answer: Inheritance

Q22: Which concept do we use for the implementation of late binding?


A) Static Functions
B) Constant Functions
C) Operator Functions
D) Virtual Functions
Answer: Virtual Functions

Q23: Which of these won’t return any value?


A) void
B) null
C) free
D) empty
Answer: void

Q24: Which function do we use for checking if a character is a space or a tab?


A) isdigit()
B) isblank()
C) isalnum()
D) isalpha()
Answer: isblank()

Q25: What would happen in case one uses a void in the passing of an argument?
A) It would return any value
B) It may not or may depend on a declared return type of any function. The return type of the
function is different from the passed arguments
C) It would return some value to the caller
D) It would not return any value to the caller
Answer: It would not return any value to the caller

Q26: __________ is an ability of grouping certain lines of code that we need to include in our
program?
A) macros

4|P ag e
VELOCIS EDUCATION C ++ MCQ MASTERY GUIDE
B) modularization
C) program control
D) specific task
Answer: modularization

Q27: Which of these keywords do we use for the declaration of the friend function?
A) myfriend
B) classfriend
C) friend
D) firend
Answer: friend

Q28: What is used for dereferencing?


A) pointer with asterix
B) pointer without asterix
C) value with asterix
D) value without asterix
Answer: pointer with asterix

Q29: What does polymorphism stand for?


A) a class that has four forms
B) a class that has two forms
C) a class that has only a single form
D) a class that has many forms
Answer: a class that has many forms

Q30: What handler do we use if we want to handle all the types of exceptions?
A) try-catch handler
B) catch-none handler
C) catch-all handler
D) catch handler
Answer: catch-all handler

Q31: What do we use in order to throw an exception?


A) try
B) throw
C) handler
D) catch
Answer: throw

Q32: We can apply RTTI to which of the class types?


A) Polymorphic
B) Encapsulation
C) Static
D) Derived

5|P ag e
VELOCIS EDUCATION C ++ MCQ MASTERY GUIDE
Answer: Polymorphic

Q33: Which header file do we use for the generation of random numbers?
A) <random>
B) <generator>
C) <distribution>
D) <gen_dist>
Answer: <random>

Q34: Which container is the best for keeping a collection of various distinct elements?
A) queue
B) set
C) heap
D) multimap
Answer: set

Q35: Inheritance models which type of relationship?


A) Part-Of relationship
B) Belongs-to relationship
C) Is-A relationship
D) Has-A relationship
Answer: Is-A relationship

Q36: In heap, which of these values will be pointed out first?


A) First value
B) Lowest value
C) Third value
D) Highest value
Answer: Highest value

Q37: Which of these functions is used for incrementing the iterator by a certain value?
A) move()
B) prev()
C) advance()
D) next()
Answer: advance()

Q38: Which of these mathematics libraries is used in C++ for vector manipulation?
A) blitz++
B) stac++
C) vec++
D) cli+++
Answer: blitz++

Q39: Which of these operators is used in order to capture every external variable by reference?

6|P ag e
VELOCIS EDUCATION C ++ MCQ MASTERY GUIDE
A) *
B) &&
C) &
D) =
Answer: =

Q40: What is the full form of oop


A) Object oriented programming
B) Oriented object programming
C) Office oriented programming
D) office objective programming
Answer: Object oriented programming

Q41: Which operator has highest precedence?


A) ()
B) =
C) *
D) ++
Answer: ()

Q42: Which operator has more precedance in below list?


A) +
B) -
C) ++
D) *
Answer: ++

Q43: Which operator can not be overloaded?


A) +
B) -
C) *
D) ::
Answer: ::

Q44: What is the size of empty class?


A) 0
B) 1
C) 2
D) 4
Answer: 1

Q45: What is abstract class?


A) A class with abstract keyword
B) A class with no functions in it
C) A class with atleast one pure virtual function

7|P ag e
VELOCIS EDUCATION C ++ MCQ MASTERY GUIDE
D) Empty Class
Answer: A class with atleast one pure virtual function

Q46: How many object can be created of a Class in C++?


A) 1
B) 5
C) There is no limit
D) 256
Answer: There is no limit

Q47: When Virtual Table is created?


A) Every Class has VTable
B) Class inherited from other Class
C) When a Class Overrides the function of Base class
D) Class has atleast one Virtual Function
Answer: Class has atleast one Virtual Function

Q48: C++ is superset of which langauge?


A) BASIC
B) VB
C) PASCAL
D) C
Answer: C

Q49: What is size of void in C++?


A) 2 Bytes
B) 4 Bytes
C) Undefined
D) 0
Answer: 0

Q50: How many Access specifier are there in C++?


A) 1
B) 2
C) 3
D) 4
Answer: 3

Q51: How to stop Name Mangling in C++?


A) It is not possible
B) It is possible only with C code
C) By using extern "C" keyword
D) By Converting C++ code to C
Answer: By using extern "C" keyword
Q52: Which of the following is Memory Leak detection tool?

8|P ag e
VELOCIS EDUCATION C ++ MCQ MASTERY GUIDE
A) GC++
B) KDevelop
C) GIT
D) Valgrind
Answer: Valgrind

Q53: Exceptions are Caught at ?


A) Compilation Time
B) Run Time
C) Linking Time
D) No
Answer: Run Time

Q54: When can we have two classes with same name?


A) We cant have
B) In different work space
C) Can have but in different file
D) We can have in any scenario
Answer: In different work space

Q55: What is Singleton class?


A) We can create n number of object
B) We can create max 256 objects
C) We can create 1 object
D) We cant create object
Answer: We can create 1 object

Q56: From which STL we can insert/remove data from anywhere?


A) Vector
B) Deque
C) Stack
D) List
Answer: List

Q57: Estimated C++ users?


A) 1 Million +
B) 2 Million +
C) 3 Million +
D) 4 Million +
Answer: 4 Million +

Q58: Which version of C++ introduced keyword - constexpr?


A) C++0x
B) C++11
C) C++1z

9|P ag e
VELOCIS EDUCATION C ++ MCQ MASTERY GUIDE
D) C++20
Answer: C++11

Q59: C++ 17 is also known as ___


A) C++ 0x
B) C++ 98
C) C++ 1z
D) C++ 11
Answer: C++ 1z

Q60: Which of the following is the least safe type casting in C++?
A) static_cast
B) const_cast
C) reinterpret_cast
D) dynamic_cast
Answer: reinterpret_cast

Q61: Which of the following is Right Shift operator?


A) <
B) <<
C) ->
D) >>
Answer: <<

Q62: ISO/IEC 14882:1998 represents which version of C++?


A) C++ 03
B) C++ 98
C) C++ 0X
D) C++ 03
Answer: C++ 98

Q63: What is the latest version of C++?


A) C++ 03
B) C++ 11
C) C++ 14
D) C++ 17
Answer: C++ 17

Q64: Which part of memory is used for the allocation of local variables declared inside any
function.
A) Heap
B) Stack
C) Address Space
D) Depends on Compiler
Answer: Stack

10 | P a g e
VELOCIS EDUCATION C ++ MCQ MASTERY GUIDE
Q65: What is the extention of the executable file produced after compiling C/C++ code using g++
on Linux?
A) .exe
B) .out
C) .lib
D) .a
Answer: .out

Q66: Which is the Parent class for all exceptions?


A) std::bad_exception
B) std::logic_error
C) std::exception
D) std::runtime_error
Answer: std::exception

Q67: Which exception is thrown when dynamic_cast fails?


A) std::bad_typeid
B) std::logic_error
C) std::runtime_error
D) std::bad_cast
Answer: std::bad_cast

Q68: Which Exception is thrown when new fails to allocate memory?


A) std::exception
B) std::bad_alloc
C) std::runtime_error
D) std::out_of_range
Answer: std::bad_alloc

Q69: Which one of the following is a keyword?


A) Size
B) Key
C) Jump
D) Switch
Answer: Switch

Q70: ____ is the smallest individual unit in a program.


A) Variable
B) Control
C) Character
D) Token
Answer: Token

Q71: What is a constant that contains a single character enclosed within single quotes?
A) Character

11 | P a g e
VELOCIS EDUCATION C ++ MCQ MASTERY GUIDE
B) Numeric
C) Fixed
D) Floating point
Answer: Character

Q72: The modulus operator uses ___ character.


A) *
B) +
C) %
D) /
Answer: %

Q73: Every variable should be separated by ___ separator.


A) Dot
B) Colon
C) Comma
D) Semicolon
Answer: Comma

Q74: Auto, static, extern and register are called as ___


A) Static
B) Register
C) Auto
D) Storage specifier
Answer: Storage specifier

Q75: How many storage specifies are there in a C++?


A) 2
B) 3
C) 5
D) 4
Answer: 4

Q76: Signed, unsigned, long and short are some of the ___
A) Void
B) Data
C) Derived data
D) Modifiers
Answer: Modifiers

Q77: Logical AND (&&) and Logical OR (||) are ___ operators.
A) Logical
B) Equality
C) Class member
D) Comma

12 | P a g e
VELOCIS EDUCATION C ++ MCQ MASTERY GUIDE
Answer: Logical

Q78: ____ operators have lower precedence to relational and arithmetic operators.
A) Conditional
B) Boolean
C) Logical
D) Relational
Answer: Relational

Q79: Variable names must begin with ___


A) #
B) $
C) Number
D) Letter
Answer: Letter

Q80: Integer values are stored in ___ bit format in binary form.
A) 8
B) 16
C) 32
D) 64
Answer: 16

Q81: Which of the following is not a C++ keyword?


A) This
B) New
C) Cont
D) If
Answer: Cont

Q82: ____ is a variable that holds a memory address.


A) Long double
B) Float
C) Char
D) Pointer
Answer: Pointer

Q83: Addressing is done using ___ number system.


A) Decimal
B) Hexadecimal
C) Octal
D) Binary
Answer: Hexadecimal

Q84: ____ Operator requires two operands.

13 | P a g e
VELOCIS EDUCATION C ++ MCQ MASTERY GUIDE
A) Logical
B) Binary
C) Unary
D) Ternary
Answer: Binary

Q85: Auto variables get undefined values known as ___


A) Garbage
B) Auto
C) Register
D) Static
Answer: Garbage

Q86: ____ storage class variables are defined in another program.


A) Register
B) Static
C) Auto
D) Extern
Answer: Extern

Q87: ____ Type is used to declare a generic pointer in C++.


A) Int
B) Void
C) Static
D) Float
Answer: Void

Q88: Which is a conditional operator?


A) @
B) <
C) >
D) ?
Answer: ?

Q89: Built in Data type is also called as ___ data type.


A) Fundamental
B) Secondary
C) Void
D) Integer
Answer: Fundamental

Q90: Rick Mascitti coined the name ___


A) Visual BASIC
B) COBOL
C) C++

14 | P a g e
VELOCIS EDUCATION C ++ MCQ MASTERY GUIDE
D) BASIC
Answer: C++

Q91: How many fundamental data types are there in C++?


A) 1
B) 2
C) 3
D) 4
Answer: 3

Q92: ____ is an operator which returns the memory size requirements in terms of bytes.
A) Double
B) Size
C) Size of
D) Long
Answer: Size of

Q93: ____ class is another qualifier that can be added to a variable declaration.
A) Register
B) Static
C) Sub
D) Storage
Answer: Storage

Q94: ____ storage class global variable known to all functions in the current program.
A) Register
B) Extern
C) Static
D) Auto
Answer: Extern

Q95: _____ are the kind of data that variables hold in a programming language.
A) Conditional type
B) Constant type
C) Variable type
D) Data types
Answer: Data types

Q96: The operands and the operators are grouped in a specific logical way of evaluation is called
____
A) Assignment
B) Association
C) Arithmetic
D) Class
Answer: Association

15 | P a g e
VELOCIS EDUCATION C ++ MCQ MASTERY GUIDE
Q97: Which one gives special meaning to the language compiler?
A) Constant
B) Variable
C) Keywords
D) Compiler
Answer: Compiler

Q98: ___ data type to indicate the function does not return a value.
A) Static
B) Main
C) Public
D) Void
Answer: Public

Q99: ___ type is further divided into int and char.


A) Float
B) Int
C) Char
D) Integral
Answer: Integral

Q100: In a class specified, data or functions and designated private are accessible
A) Only to public members of class
B) Only if you know the password
C) To any function in the program
D) To member functions of that class
Answer: To member functions of that class

Q101: Keyword typed is used to declare


A) A synonym for an existing type
B) Absence of a type
C) Objects that can be modified outside of a program control
D) A member function that is defined in a subclass
Answer: Absence of a type

Q102: In C++ programming language, to write data that contains variables of type flat to an object
of type of stream, which of the following should be used?
A) Put ( )
B) Seekg ( )
C) Write ( )
D) Insertion operator
Answer: Write ( )
Q103: The special characters like tab, backspace, line feed, null, back slash are called ____
character constant
A) Floating

16 | P a g e
VELOCIS EDUCATION C ++ MCQ MASTERY GUIDE
B) String
C) Graphic
D) Non-graphic
Answer: Non-graphic

Q104: The sequence of digits starting with 0 is treated as ___ constant.


A) Penta
B) Hexadecimal
C) Binary
D) Octal
Answer: Octal

Q105: For example class boy, ____ is a user defined data type of class.
A) Class
B) Type
C) Boy
D) User
Answer: Boy

Q106: When a=6, c= ++a what will be the value of c?


A) 6
B) 7
C) 8
D) 9
Answer: 7

Q107: When a=6 and c=a++ what is the value of c?


A) 6
B) 7
C) 8
D) 9
Answer: 6

Q108: What is the default file extension for all Word documents?
A) FIL
B) DOC
C) WRD
D) TXT
Answer: DOC

Q109: The ____ key and the ___ key can be used in combination with other keys to perform
shortcuts and special tasks.
A) Control, Alt
B) Function, toggle
C) Delete, Insert

17 | P a g e
VELOCIS EDUCATION C ++ MCQ MASTERY GUIDE
D) Caps Lock, Num Lock
Answer: Control, Alt

Q110: ____ literals are treated as array of characters.


A) Graphic
B) String
C) Non- graphic
D) Character
Answer: String

Q111: Which one holds the values or constants in memory boxes?


A) Variable
B) While
C) Goto
D) Switch
Answer: Variable

Q112: The programming language that has the ability to create new data types is
called_______________
A) Overloaded
B) Extensible
C) Reprehensible
D) Encapsulated
Answer: Extensible

Q113: Which of the following is the correct syntax to read the single character to console in the
C++ language?
A) get(ch)
B) Scanf(ch)
C) Read ch()
D) Getline vh()
Answer: get(ch)

Q114: If we stored five elements or data items in an array, what will be the index address or the
index number of the array’s last data item?
A) 88
B) 4
C) 5
D) 3
Answer: 4

Q115: How many types of the array are there in the C++ programming language?
A) In the C++ programming language, there are four types of arrays
B) In the C++ programming language, there are three types of arrays

18 | P a g e
VELOCIS EDUCATION C ++ MCQ MASTERY GUIDE
C) In the C++ programming language, there are two types of arrays
D) In the C++ programming language, there are six types of arrays
Answer: In the C++ programming language, there are two types of arrays

Q116: Which of the following can be considered as the correct syntax for declaring an array of
pointers of integers that has a size of 10 in C++?
A) int *arr = new int*[10]
B) int *arr = new int[10];
C) int arr = new int[10];
D) int **arr = new int*[10];
Answer: int **arr = new int*[10];

Q117: In which type of constant the Decimal numbers, integer and floating-point are related?
A) Numeric
B) String
C) Char
D) Boolean
Answer: Numeric

Q118: The basic types are collectively called as ___


A) Looping
B) Tokens
C) Expression
D) Variables
Answer: Looping

Q119: ____ are data items whose value cannot be changed.

A) Class
B) Return
C) Constants
D) Variable
Answer: Constants

Q120: Every variable will be referred by its ___


A) Data
B) Int
C) Name
D) Address
Answer: Address

Q121: Which storage class defines local variable known to the block in which they are defined?
A) Register
B) Auto
C) Extern

19 | P a g e
VELOCIS EDUCATION C ++ MCQ MASTERY GUIDE
D) Static
Answer: Auto

Q122: ____ allows users to define the user defined data type identifier.
A) Class
B) Data
C) Identifier
D) Type definition
Answer: Type definition

Q123: What is the length of long double data type?


A) 16
B) 8
C) 32
D) 80
Answer: 80

Q124: The names beginning with an underscore are reserved for _____ variable.
A) Globar
B) Local
C) Internal system
D) External system
Answer: Internal system

Q125: Which punctuator is used to group a set of C++ statements?

A) {}

B) []
C) ()
D) /

Answer: {}

Q126: ____ refers to the process of changing the data type of the value stored in a variable.
A) Type char
B) Type Int
C) Type Float
D) Type cast
Answer: Type cast

Q127: ____ data types are structure, union, class and enumeration.
A) Derived

20 | P a g e
VELOCIS EDUCATION C ++ MCQ MASTERY GUIDE
B) Integer
C) Built-in
D) User defined
Answer: User defined

Q128: Which operator is used to compare numerical values?


A) Relational
B) Conditional
C) Assignment
D) Arithmetic
Answer: Relational

Q129: ____ allocates memory, based on the data type of the variable.
A) Interpreter
B) Link
C) Converter
D) Compiler
Answer: Compiler
Q130: Redirection redirects
A) Screen from a device to a stream
B) A device from the screen to a file
C) A stream from a file to the screen
D) A file from a device to a stream
Answer: A stream from a file to the screen

Q131: The scope resolution operator usually


A) Providing a useful conceptual frame work
B) Specifies a particular class
C) Tells what base class is derived from
D) Limits the visibility of variables to a certain function
Answer: Specifies a particular class

Q132: A variable defined within a block is visible


A) From the point of definition onward in the block
B) From the point of definition on ward in the function
C) From the point of definition on ward in the program
D) Throughout the function
Answer: From the point of definition onward in the block

Q133: The library function exit( ) causes an exit from

A) The program in which it occurs

B) The function in which it occurs

21 | P a g e
VELOCIS EDUCATION C ++ MCQ MASTERY GUIDE

C) The block in which it occurs

D) The loop in which it occurs


Answer: The program in which it occurs

Q134: The dot operator connects which of the following two entities?
A) Class object and member of that class
B) Class and member of that class
C) Class object and a class
D) Class member and class object
Answer: Class object and member of that class

Q135: A static function

A) Should be called when an object is destroyed


B) Can be called using the class name and function
C) Is closely connected with an individual object of a class
D) Is used when a dummy object must be created
Answer: Can be called using the class name and function
Q136: The function bad( ) is declared in the header file
A) <iostream.h>
B) <stdio.h>
C) <math.h>
D) <stdlib.h>
Answer: <math.h>

Q137: The break statement causes an exit


A) From the innermost loop or switch
B) Only from the innermost switch
C) Only from the innermost loop
D) From all loops and switches
Answer: From all loops and switches

Q138: Element double array [7] is which element of the array?


A) Sixth
B) Seventh
C) Eighth
D) Impossible
Answer: Eighth

Q139: In a linked list


A) Each link contains data or a pointer to data
B) Links are stored in an array
C) A array of pointers point to the link

22 | P a g e
VELOCIS EDUCATION C ++ MCQ MASTERY GUIDE
D) Each link contains a pointer to the next link
Answer: Each link contains a pointer to the next link

Q140: The public files in a class library usually contain


A) Variable definition
B) Class declarations
C) Constant definitions
D) Member function definitions
Answer: Class declarations

Q141: The member function can always access the data in


A) Any object of the class of which it is a member
B) The public part of its class
C) The class of which it is member
D) The object of which is a member
Answer: The object of which is a member

Q142: In a stock, the data item placed on the stack first is


A) Given as index zero
B) Not given as index number
C) The first data item to be removed
D) The last data item to be removed
Answer: The last data item to be removed

Q143: Breaking a program into several files is desirable because


A) A program can be divided functionally
B) Each programmer can work on a separate file
C) Some files don’t need to be recompiled each time
D) Files can be marketed in object form
Answer: A program can be divided functionally

Q144: In new operator


A) Each link contains data or a pointer to data
B) Each link contains a pointer to the next link
C) Links are stored in an array
D) An array of pointers point to the links
Answer: Each link contains a pointer to the next link

Q145: The keyword void is used to declare


A) Objects that can be modified outside of program control
B) synonym for an existing type
C) A member function that is defined in a subclass
D) Absence of a type
Answer: A member function that is defined in a subclass

23 | P a g e
VELOCIS EDUCATION C ++ MCQ MASTERY GUIDE
Q146: Classes are useful because they
A) Can closely model objects in the real world
B) Bring together all aspects of an entity in one place
C) Permit data to be hidden from other classes
D) Are removed from memory when not in use
Answer: Permit data to be hidden from other classes

Q147: A base class


A) behave badly when chips are down
B) will be a generalized version of its derived classes
C) correspond to something in the real world
D) offer model more specific objects than its derived classes
Answer: will be a generalized version of its derived classes

Q148: Copy constructor is invoked when a/an


A) Argument is passed by value
B) Argument is passed by reference
C) Function returns for reference
D) Function returns by value
Answer: Function returns by value

Q149: A project file


A) contains instructions for compiling and linking
B) contains definitions for C++ variables
C) examines contents of the files in the project
D) examines contents of the files in the project
Answer: contains instructions for compiling and linking

Q150: #include<userdefined.h> Which of the following is the correct syntax to add the header file
in the C++ program?
A) #include<userdefined>
B) #include "userdefined.h"
C) <include> "userdefined.h"
D) Both #include<userdefined> , #include "userdefined.h"
Answer: Both #include<userdefined> , #include "userdefined.h"

151. Which of the following is used for comments in C++?


a) /* comment */
b) // comment */
c) // comment
d) both // comment or /* comment */

Ans : d) both // comment or /* comment */

24 | P a g e
VELOCIS EDUCATION C ++ MCQ MASTERY GUIDE
152. What is virtual inheritance in C++?
a) C++ technique to enhance multiple inheritance
b) C++ technique to ensure that a private member of the base class can be accessed somehow
c) C++ technique to avoid multiple inheritances of classes
d) C++ technique to avoid multiple copies of the base class into children/derived class

Ans: d) C++ technique to avoid multiple copies of the base class into children/derived class

153. What is the difference between delete and delete[] in C++?


a) delete is syntactically correct but delete[] is wrong and hence will give an error if used in any case
b) delete is used to delete normal objects whereas delete[] is used to pointer objects
c) delete is a keyword whereas delete[] is an identifier
d) delete is used to delete single object whereas delete[] is used to multiple(array/pointer of) objects

Ans : d) delete is used to delete single object whereas delete[] is used to multiple(array/pointer of)
objects

154. Which of the following is correct about this pointer in C++?


a) this pointer is passed as a hidden argument in all static variables of a class
b) this pointer is passed as a hidden argument in all the functions of a class
c) this pointer is passed as a hidden argument in all non-static functions of a class
d) this pointer is passed as a hidden argument in all static functions of a class

Ans: c) this pointer is passed as a hidden argument in all non-static functions of a class

155. What is abstract class in C++?


a) Any Class in C++ is an abstract class
b) Class from which any class is derived
c) Class specifically used as a base class with atleast one virtual functions
d) Class specifically used as a base class with atleast one pure virtual functions

Ans : d) Class specifically used as a base class with atleast one pure virtual functions

156. Which of the following constructors are provided by the C++ compiler if not defined in a class?
a) Copy constructor
b) Default constructor
c) Assignment constructor
d) All of the mentioned

Ans : d) All of the mentioned

157. How structures and classes in C++ differ?


a) Structures by default hide every member whereas classes do not
b) In Structures, members are public by default whereas, in Classes, they are private by default
c) Structures cannot have private members whereas classes can have
d) In Structures, members are private by default whereas, in Classes, they are public by default

25 | P a g e
VELOCIS EDUCATION C ++ MCQ MASTERY GUIDE
Ans: b) In Structures, members are public by default whereas, in Classes, they are private by default

158 What is the benefit of c++ input and output over c input and output?
a) Both Type safety & Exception
b) Sequence container
c) Exception
d) Type safety

Ans : d) Type safety

159. Wrapping data and its related functionality into a single entity is known as _____________
a) Abstraction
b) Encapsulation
c) Polymorphism
d) Modularity

Ans : b) Encapsulation

160. What does polymorphism in OOPs mean?


a) Concept of allowing overiding of functions
b) Concept of hiding data
c) Concept of keeping things in differnt modules/files
d) Concept of wrapping things into a single unit

Ans : a) Concept of allowing overiding of functions

161. Which concept allows you to reuse the written code?


a) Encapsulation
b) Abstraction
c) Inheritance
d) Polymorphism

Ans : c) Inheritance

162. Which of the following shows multiple inheritances?


a) A->B->C
b) A->B; A->C
c) A,B->C
d) B->A

Ans : c) A,B->C

163. How access specifiers in Class helps in Abstraction?


a) They does not helps in any way
b) They allows us to show only required things to outer world
c) They help in keeping things together
d) Abstraction concept is not used in classes

26 | P a g e
VELOCIS EDUCATION C ++ MCQ MASTERY GUIDE
Ans : b) They allows us to show only required things to outer world

164. C++ is ______________


a) procedural programming language
b) object oriented programming language
c) functional programming language
d) both procedural and object oriented programming language

Ans : d) both procedural and object oriented programming language

165. What does modularity mean?


a) Hiding part of program
b) Subdividing program into small independent parts
c) Overriding parts of program
d) Wrapping things into single unit

Ans : b) Subdividing program into small independent parts

166. Which of the following class allows to declare only one object of it?
a) Abstract class
b) Virtual class
c) Singleton class
d) Friend class

Ans : c) Singleton class

167. Which of the following is not a type of Constructor?


a) Friend constructor
b) Copy constructor
c) Default constructor
d) Parameterized constructor

Ans : a) Friend constructor

168. Which of the following is correct?


a) Base class pointer object cannot point to a derived class object
b) Derived class pointer object cannot point to a base class object
c) A derived class cannot have pointer objects
d) A base class cannot have pointer objects

Ans : b) Derived class pointer object cannot point to a base class object

169. Out of the following, which is not a member of the class?


a) Static function
b) Friend function
c) Constant function
d) Virtual function

27 | P a g e
VELOCIS EDUCATION C ++ MCQ MASTERY GUIDE
Ans : b) Friend function

170. What is the other name used for functions inside a class?
a) Member variables
b) Member functions
c) Class functions
d) Class variables

Ans : b) Member functions

171. Which of the following cannot be a friend?


a) Function
b) Class
c) Object
d) Operator function

Ans : c) Object

172. Why references are different from pointers?


a) A reference cannot be made null
b) A reference cannot be changed once initialized
c) No extra operator is needed for dereferencing of a reference
d) All of the mentioned

Ans : d) All of the mentioned

173. Which of the following provides a programmer with the facility of using object of a class inside other
classes?
a) Inheritance
b) Composition
c) Abstraction
d) Encapsulation

Ans : b) Composition

174. How many types of polymorphism are there in C++?


a) 1
b) 2
c) 3
d) 4

Ans : b) 2

175. How run-time polymorphisms are implemented in C++?


a) Using Inheritance
b) Using Virtual functions

28 | P a g e
VELOCIS EDUCATION C ++ MCQ MASTERY GUIDE
c) Using Templates
d) Using Inheritance and Virtual functions

Ans : d) Using Inheritance and Virtual functions

176.How compile-time polymorphisms are implemented in C++?


a) Using Inheritance
b) Using Virtual functions
c) Using Templates
d) Using Inheritance and Virtual functions

Ans : c) Using Templates

177. Which of the following is an abstract data type?


a) int
b) float
c) class
d) string

Ans : b) float

178. Which concept means the addition of new components to a program as it runs?
a) Data hiding
b) Dynamic binding
c) Dynamic loading
d) Dynamic typing

ANS : c) Dynamic loading

179. Which of the following explains the overloading of functions?


a) Virtual polymorphism
b) Transient polymorphism
c) Ad-hoc polymorphism
d) Pseudo polymorphism

ANS : c) Ad-hoc polymorphism

180. Which operator is overloaded for a cout object?


a) >>
b) <<
c) <
d) >

ANS : b) <<

181. Which of the following cannot be used with the virtual keyword?
a) Class

29 | P a g e
VELOCIS EDUCATION C ++ MCQ MASTERY GUIDE
b) Member functions
c) Constructors
d) Destructors

ANS : c) Constructors

182. Which concept is used to implement late binding?


a) Virtual functions
b) Operator functions
c) Constant functions
d) Static functions

ANS : a) Virtual functions

183. Which of the following is correct?


a) C++ allows static type checking
b) C++ allows dynamic type checking.
c) C++ allows static member function to be of type const.
d) C++ allows both static and dynamic type checking

ANS : d) C++ allows both static and dynamic type checking

184. Which of the following supports the concept that reusability is a desirable feature of a language?
a) It reduces the testing time
b) It reduces maintenance cost
c) It decreases the compilation time
d) It reduced both testing and maintenance time

ANS : d) It reduced both testing and maintenance time

185. Which of the following is a static polymorphism mechanism?


a) Function overloading
b) Operator overloading
c) Templates
d) All of the mentioned

ANS : d) All of the mentioned

186. Which of the following is true?


I) All operators in C++ can be overloaded.
II) The basic meaning of an operator can be changed.
a) I only
b) II only
c) Both I and II
d) Neither I nor II

ANS : d) Neither I nor II

30 | P a g e
VELOCIS EDUCATION C ++ MCQ MASTERY GUIDE
187. Which of the following is not a type of inheritance?
a) Multiple
b) Multilevel
c) Distributive
d) Hierarchical

ANS : c) Distributive

188. What happens if a class does not have a name?


a) It will not have a constructor
b) It will not have a destructor
c) It is not allowed
d) It will neither have a constructor or destructor

ANS : b) It will not have a destructor

189. Which of the following statement is true?


I) In Procedural programming languages, all function calls are resolved at compile-time
II) In Object Oriented programming languages, all function calls are resolved at compile-time
a) I only
b) II only
c) Both I and II
d) Neither I nor II

ANS : a) I only

190. Which members are inherited but are not accessible in any case?
a) Private
b) Public
c) Protected
d) Both private and protected

ANS : a) Private

191. Which of the following is correct?


a) Friend functions can access public members of a class
b) Friend functions can access protected members of a class
c) Friend functions can access private members of a class
d) All of the mentioned

ANS : d) All of the mentioned

192. Which of the following is correct in C++?


a) Classes cannot have protected data members
b) Structures can have member functions

31 | P a g e
VELOCIS EDUCATION C ++ MCQ MASTERY GUIDE
c) Class members are public by default
d) Structure members are private by default

ANS : b) Structures can have member functions

193. Which of the following is used to make an abstract class?


a) By using virtual keyword in front of a class declaration
b) By using an abstract keyword in front of a class declaration
c) By declaring a virtual function in a class
d) By declaring a pure virtual function in a class

AND : d) By declaring a pure virtual function in a class

194. Which of the following is correct?


a) A class is an instance of its objects
b) An object is an instance of its class
c) A class is an instance of the data type that the class have
d) An object is an instance of the data type of the class

ANS : b) An object is an instance of its class

195. Which of the following is not a fundamental type is not present in C but present in C++?
a) int
b) float
c) bool
d) void

ANS : c) bool

196. What is the size of a boolean variable in C++?


a) 1 bit
b) 1 byte
c) 4 bytes
d) 2 bytes

ANS : a) 1 bit

197. Which of the following is C++ equivalent for scanf()?


a) cin
b) cout
c) print
d) input

ANS : a) cin

198. Which of the following is C++ equivalent for printf()?


a) cin

32 | P a g e
VELOCIS EDUCATION C ++ MCQ MASTERY GUIDE
b) cout
c) print
d) input

ANS : b) cout

199. Which of the following is the correct difference between cin and scanf()?
a) both are the same
b) cin is a stream object whereas scanf() is a function
c) scanf() is a stream object whereas cin is a function
d) cin is used for printing whereas scanf() is used for reading inpu0074

ANS : b) cin is a stream object whereas scanf() is a function

200. Which of the following is an exit-controlled loop?


a) for
b) while
c) do-while
d) all of the mentioned

ANS : c) do-while

201. Which of the following is an entry-controlled loop?


a) for
b) while
c) do-while
d) both while and for

ANS : d) both while and for

202. What is dynamic binding?


a) The process of linking the actual code with a procedural call during run-time
b) The process of linking the actual code with a procedural call during compile-time
c) The process of linking the actual code with a procedural call at any-time
d) All of the mentioned

ANS : a) The process of linking the actual code with a procedural call during run-time

203. What is static binding?


a) The process of linking the actual code with a procedural call during run-time
b) The process of linking the actual code with a procedural call during compile-time
c) The process of linking the actual code with a procedural call at any-time
d) All of the mentioned

ANS : b) The process of linking the actual code with a procedural call during compile-time

33 | P a g e
VELOCIS EDUCATION C ++ MCQ MASTERY GUIDE
204. What is name mangling in C++?
a) The process of adding more information to a function name so that it can be distinguished from other
functions by the compiler
b) The process of making common names for all the function of C++ program for better use
c) The process of changing the names of variable
d) The process of declaring variables of different types

ANS : a) The process of adding more information to a function name so that it can be distinguished from
other functions by the compiler

205. Which of the following syntax for declaring a variable of struct STRUCT can be used in both C and
C++?
a) struct STRUCT S;
b) STRUCT S;
c) Both struct STRUCT S; and STRUCT S;
d) Both C and C++ have different syntax

ANS : a) struct STRUCT S;

206. What if we define the below structure in C and C++?


a) Error in C but not in C++
b) Error in C++ but not in C
c) No error in both C and C++
d) Error in both C and C++

ANS : a) Error in C but not in C++

207. Pick the odd one out.


a) array type
b) character type
c) boolean type
d) integer type

ANS : a) array type

208. Which data type is used to represent the absence of parameters?


a) int
b) short
c) void
d) float

ANS : c) void

209. What does ‘\a’ escape code represent?


a) alert
b) backslash

34 | P a g e
VELOCIS EDUCATION C ++ MCQ MASTERY GUIDE
c) tab
d) form feed

ANS : a) alert

210. Which type is best suited to represent the logical values?


a) integer
b) boolean
c) character
d) float

ANS : b) Boolean

211. Identify the user-defined types from the following?


a) enumeration
b) classes
c) both enumeration and classes
d) int

ANS : c) both enumeration and classes

212. Which of the following statements are true? int f(float)

a) f is a function taking an argument of type int and returning a floating point number
b) f is a function taking an argument of type float and returning an integer
c) f is a function of type float
d) f is a function of type int

ANS : b) f is a function taking an argument of type float and returning an integer

213. The value 132.54 can be represented using which data type?
a) double
b) void
c) int
d) bool

ANS : a) double

214. When a language has the capability to produce new data type mean, it can be called as
a) overloaded
b) extensible
c) encapsulated
d) reprehensible

AND : b) extensible

35 | P a g e
VELOCIS EDUCATION C ++ MCQ MASTERY GUIDE
215. Is bool a fundamental data type in C++?
a) Yes
b) No, it is a typedef of unsigned char
c) No, it is an enum of {false, true}
d) No, it is expanded from macros

ANS : a) Yes

216. Find the odd one out.


a) std::vector<int>
b) std::vector<short>
c) std::vector<long>
d) std::vector<bool>

ANS : d) std::vector<bool>

217. What happens when a null pointer is converted into bool?


a) an error is flagged
b) bool value evaluates to true
c) bool value evaluates to false
d) the statement is ignored

ANS : c) bool value evaluates to false

218. Which of the following statements are false?


a) bool can have two values and can be used to express logical expressions
b) bool cannot be used as the type of the result of the function
c) bool can be converted into integers implicitly
d) a bool value can be used in arithmetic expressions

ANS : b) bool cannot be used as the type of the result of the function

219. For what values of the expression is an if-statement block not executed?
a) 0 and all negative values
b) 0 and -1
c) 0
d) 0, all negative values, all positive values except 1

ANS: c) 0

220. Which of the two operators ++ and — work for the bool data type in C++?
a) None
b) ++
c) —
d) ++ & —

ANS : b) ++

36 | P a g e
VELOCIS EDUCATION C ++ MCQ MASTERY GUIDE
221. The size_t integer type in C++ is?
a) Unsigned integer of at least 64 bits
b) Signed integer of at least 16 bits
c) Unsigned integer of at least 16 bits
d) Signed integer of at least 64 bits

ANS : c) Unsigned integer of at least 16 bits

222. Which of these expressions will return true if the input integer v is a power of two?
a) (v | (v + 1)) == 0;
b) (~v & (v – 1)) == 0;
c) (v | (v – 1)) == 0;
d) (v & (v – 1)) == 0;

ANS : d) (v & (v – 1)) == 0;

223. Which of these expressions will make the rightmost set bit zero in an input integer x?
a) x = x | (x-1)
b) x = x & (x-1)
c) x = x | (x+1)
d) x = x & (x+2)

ANS : b) x = x & (x-1)

224. Which of these expressions will isolate the rightmost set bit?
a) x = x & (~x)
b) x = x ^ (~x)
c) x = x & (-x)
d) x = x ^ (-x)

ANS : c) x = x & (-x)

225. 0946, 786427373824, ‘x’ and 0X2f are _____ _____ ____ and _____ literals respectively.
a) decimal, character, octal, hexadecimal
b) octal, hexadecimal, character, decimal
c) hexadecimal, octal, decimal, character
d) octal, decimal, character, hexadecimal

ANS : d) octal, decimal, character, hexadecimal

226. Which of the following is not one of the sizes of the floating point types?
a) short float
b) float
c) long double
d) double

ANS : a) short float

37 | P a g e
VELOCIS EDUCATION C ++ MCQ MASTERY GUIDE
227. Which of the following is a valid floating-point literal?
a) f287.333
b) F287.333
c) 287.e2
d) 287.3.e2

ANS : c) 287.e2

228. What is the range of the floating point numbers?


a) -3.4E+38 to +3.4E+38
b) -3.4E+38 to +3.4E+34
c) -3.4E+38 to +3.4E+36
d) -3.4E+38 to +3.4E+32

ANS : a) -3.4E+38 to +3.4E+38

229. Which of three sizes of floating point types should be used when extended precision is required?
a) float
b) double
c) long double
d) extended float

ANS : c) long double

230. Which is used to indicate single precision value?


a) F or f
b) L or l
c) Either F or for L or l
d) Neither F or for L or l

ANS : a) F or f

231. Which is correct with respect to the size of the data types?
a) char > int < float
b) int < char > float
c) char < int < float
d) char < int < double

ANS : d) char < int < double

232. The size of an object or a type can be determined using which operator?
a) malloc
b) sizeof
c) malloc
d) calloc

ANS : b) sizeof

38 | P a g e
VELOCIS EDUCATION C ++ MCQ MASTERY GUIDE
233. It is guaranteed that a ____ has at least 8 bits and a ____ has at least 16 bits.
a) int, float
b) char, int
c) bool, char
d) char, short

AND : d) char, short

234. Implementation dependent aspects about an implementation can be found in ____


a) <implementation>
b) <limits>
c) <limit>
d) <numeric>

ANS : b) <limits>

235. Size of C++ objects are expressed in terms of multiples of the size of a ____ and the size of a char is
_______
a) char, 1
b) int, 1
c) float, 8
d) char, 4

ANS : a) char, 1

236. Identify the incorrect option.


a) 1 <= sizeof(bool) <= sizeof(long)
b) sizeof(float) <= sizeof(double) <= sizeof(long double)
c) sizeof(char) <= sizeof(long) <=sizeof(wchar_t)
d) sizeof(N) = sizeof(signed N) = sizeof(unsigned N)

ANS : c) sizeof(char) <= sizeof(long) <=sizeof(wchar_t)

237. Which of the following will not return a value?


a) null
b) void
c) empty
d) free

ANS : b) void

238. ______________ have the return type void.


a) all functions
b) constructors
c) destructors
d) none of the mentioned

39 | P a g e
VELOCIS EDUCATION C ++ MCQ MASTERY GUIDE
AND : d) none of the mentioned

239. Choose the incorrect option.


a) void is used when the function does not return a value
b) void is also used when the value of a pointer is null
c) void is used as the base type for pointers to objects of unknown type
d) void is a special fundamental type

ANS : b) void is also used when the value of a pointer is null

240. Identify the incorrect option.


a) enumerators are constants
b) enumerators are user-defined types
c) enumerators are same as macros
d) enumerator values start from 0 by default

ANS : c) enumerators are same as macros

241. In which type do the enumerators are stored by the compiler?


a) string
b) integer
c) float
d) string & float

ANS : b) integer

242. To which of these enumerators can be assigned?


a) integer
b) negative
c) enumerator
d) all of the mentioned

ANS : d) all of the mentioned

243. What will happen when defining the enumerated type?


a) it will not allocate memory
b) it will allocate memory
c) it will not allocate memory to its variables
d) allocate memory to objects

ANS : a) it will not allocate memory

244. Which variable does equals in size with enum variable?


a) int variable
b) float variable
c) string variable
d) float & string variable

40 | P a g e
VELOCIS EDUCATION C ++ MCQ MASTERY GUIDE
ANS : a) int variable

245. Which of the following correctly declares an array?


a) int array[10];
b) int array;
c) array{10};
d) array array[10];

Ans : a) int array[10];

246. What is the index number of the last element of an array with 9 elements?
a) 9
b) 8
c) 0
d) Programmer-defined

Ans : b) 8

247. What is the correct definition of an array?


a) An array is a series of elements of the same type in contiguous memory locations
b) An array is a series of element
c) An array is a series of elements of the same type placed in non-contiguous memory locations
d) An array is an element of the different type

Ans : a) An array is a series of elements of the same type in contiguous memory locations

248. Which of the following accesses the seventh element stored in array?
a) array[6];
b) array[7];
c) array(7);
d) array;

Ans : a) array[6];

249. Which of the following gives the memory address of the first element in array?
a) array[0];
b) array[1];
c) array(2);
d) array;

Ans : d) array;

250. What is the meaning of the following declaration?

int(*p[5])();

41 | P a g e
VELOCIS EDUCATION C ++ MCQ MASTERY GUIDE
a) p is pointer to function
b) p is array of pointer to function
c) p is pointer to such function which return type is the array
d) p is pointer to array of function

Ans : b) p is array of pointer to function

251. What is size of generic pointer in C++ (in 32-bit platform)?


a) 2
b) 4
c) 8
d) 0

ANS : b) 4

252. The constants are also called as _____________


a) const
b) preprocessor
c) literals
d) variables

ANS : c) literals

253. What are the parts of the literal constants?


a) integer numerals
b) floating-point numerals
c) strings and boolean values
d) all of the mentioned

ANS : d) all of the mentioned

254. How are the constants declared?


a) const keyword
b) #define preprocessor
c) both const keyword and #define preprocessor
d) $define

ANS : c) both const keyword and #define preprocessor

255. Which of the following statement is not true about preprocessor directives?
a) These are lines read and processed by the preprocessor
b) They do not produce any code by themselves
c) These must be written on their own line
d) They end with a semicolon

ANS : d) They end with a semicolon

42 | P a g e
VELOCIS EDUCATION C ++ MCQ MASTERY GUIDE
256. The difference between x and ‘x’ is?
a) The first one refers to a variable whose identifier is x and the second one refers to the character
constant x
b) The first one is a character constant x and the second one is the string literal x
c) Both are same
d) Both are string literal

ANS : a) The first one refers to a variable whose identifier is x and the second one refers to the character
constant x

257. How to declare a wide character in the string literal?


a) L prefix
b) l prefix
c) W prefix
d) Z prefix

ANS : a) L prefix

258. What are the references in C++?


a) An alternative name for already existing variables
b) A pointer to a variable
c) A new type of variables
d) A new type of constant variable

ANS : a) An alternative name for already existing variables

259. What is the difference between references and pointers?


a) References are an alias for a variable whereas pointer stores the address of a variable
b) References and pointers are similar
c) References stores address of variables whereas pointer points to variables
d) Pointers are an alias for a variable whereas references stores the address of a variable

ANS : a) References are an alias for a variable whereas pointer stores the address of a variable

260. Pick the correct statement about references in C++.


a) References stores the address of variables
b) References and variables both have the same address
c) References use dereferencing operator(*) to access the value of variable its referencing
d) References were also available in C

ANS : b) References and variables both have the same address

261. Pick the correct statement about references.


a) References can be assigned value NULL
b) References once assigned cannot be changed to refer another variable

43 | P a g e
VELOCIS EDUCATION C ++ MCQ MASTERY GUIDE
c) Reference should not be initialized when created
d) Reference is the same as pointers

ANS : b) References once assigned cannot be changed to refer another variable

262. Which of the following operator is used while declaring references?


a) *
b) &
c) ^
d) ->

ANS : b) &

263. How many Destructors are allowed in a Class?


a) 1
b) 2
c) 3
d) Any number

ANS: a) 1

264. How many types of constructors are available, in general, in any language?
a) 2
b) 3
c) 4
d) 5

ANS : b) 3

265. Which constructor is called while assigning some object with another?
a) Default
b) Parameterized
c) Copy
d) Direct assignment is used

ANS: c) Copy

266. It’s necessary to pass object by reference in copy constructor because ____________
a) Constructor is not called in pass by reference
b) Constructor is called in pass by reference only
c) It passes the address of new constructor to be created
d) It passes the address of new object to be created

ANS : a) Constructor is not called in pass by reference

267. Which specifier applies only to the constructors?


a) Public

44 | P a g e
VELOCIS EDUCATION C ++ MCQ MASTERY GUIDE
b) Protected
c) Implicit
d) Explicit

ANS : d) Explicit

268. Which among the following is true?


a) Default constructor can’t be defined by the programmer
b) Default parameters constructor isn’t equivalent to the default constructor
c) Default constructor can be called explicitly
d) Default constructor is and always called implicitly only

ANS : c) Default constructor can be called explicitly

269. Which type of constructor can’t have a return type?


a) Default
b) Parameterized
c) Copy
d) Constructors don’t have a return type

ANS : d) Constructors don’t have a return type

270. Why do we use static constructors?


a) To initialize the static members of class
b) To initialize all the members with static value
c) To delete the static members when not required
d) To clear all the static members initialized values

ANS : a) To initialize the static members of class

271. When and how many times a static constructor is called?


a) Created at time of object destruction
b) Called at first time when an object is created and only one time
c) Called at first time when an object is created and called with every new object creation
d) Called whenever an object go out of scope

ANS : b) Called at first time when an object is created and only one time

272. Which among the following is true for static constructor?


a) Static constructors are called with every new object
b) Static constructors are used initialize data members to zero always
c) Static constructors can’t be parameterized constructors
d) Static constructors can be used to initialize the non-static members also

ANS : c) Static constructors can’t be parameterized constructors

45 | P a g e
VELOCIS EDUCATION C ++ MCQ MASTERY GUIDE
273. Within a class, only one static constructor can be created.
a) True
b) False

ANS : a) True

274. Default constructor initializes all data members as ___________


a) All numeric member with some garbage values and string to random string
b) All numeric member with some garbage values and string to null
c) All numeric member with zero and strings to random value
d) All numeric member with zero and strings to null

ANS : d) All numeric member with zero and strings to null

275. When is the static constructor called?


a) After the first instance is created
b) Before default constructor call of first instance
c) Before first instance is created
d) At time of creation of first instance

ANS : c) Before first instance is created

276. If constructors of a class are defined in private access, then __________


a) The class can’t be inherited
b) The class can be inherited
c) Instance can be created only in another class
d) Instance can be created anywhere in the progra

ANS : a) The class can’t be inherited

277. Copy constructor is a constructor which ________________


a) Creates an object by copying values from any other object of same class
b) Creates an object by copying values from first object created for that class
c) Creates an object by copying values from another object of another class
d) Creates an object by initializing it with another previously created object of same class

ANS : d) Creates an object by initializing it with another previously created object of same class

278. The copy constructor can be used to ____________


a) Initialize one object from another object of same type
b) Initialize one object from another object of different type
c) Initialize more than one object from another object of same type at a time
d) Initialize all the objects of a class to another object of another class

ANS : a) Initialize one object from another object of same type

46 | P a g e
VELOCIS EDUCATION C ++ MCQ MASTERY GUIDE
279. If two classes have exactly same data members and member function and only they differ by class
name. Can copy constructor be used to initialize one class object with another class object?
a) Yes, possible
b) Yes, because the members are same
c) No, not possible
d) No, but possible if constructor is also same

ANS : c) No, not possible

280. The copy constructors can be used to ________


a) Copy an object so that it can be passed to a class
b) Copy an object so that it can be passed to a function
c) Copy an object so that it can be passed to another primitive type variable
d) Copy an object for type casting

ANS : b) Copy an object so that it can be passed to a function

281. The data elements in the structure are also known as what?
a) objects
b) members
c) data
d) objects & data

Ans : b) members

282. What will be used when terminating a structure?


a) :
b) }
c) ;
d) ;;

Ans : c) ;

283. What will happen when the structure is declared?


a) it will not allocate any memory
b) it will allocate the memory
c) it will be declared and initialized
d) it will be declared

Ans : a) it will not allocate any memory

284. The declaration of the structure is also called as?


a) structure creator
b) structure signifier

47 | P a g e
VELOCIS EDUCATION C ++ MCQ MASTERY GUIDE
c) structure specifier
d) structure creator & signifier

Ans : c) structure specifier

285. Which of the following is a properly defined structure?


a) struct {int a;}
b) struct a_struct {int a;}
c) struct a_struct int a;
d) struct a_struct {int a;};

Ans : d) struct a_struct {int a;};

286. Which of the following accesses a variable in structure *b?


a) b->var;
b) b.var;
c) b-var;
d) b>var;

Ans : a) b->var;

287. Which function is used to check whether a character is an alphabet?


a) isalpha()
b) isalnum()
c) isdigit()
d) isblank()

Ans : a) isalpha()

288. Which function is used to check whether a character is an alphabet or number?


a) isalpha()
b) isalnum()
c) isdigit()
d) isblank()

Ans : b) isalnum()

289. Which function is used to check whether a character is a number?


a) isalpha()
b) isalnum()
c) isdigit()
d) isblank()

Ans : c) isdigit()

290. Which function is used to check whether a character is a tab or space?


a) isalpha()

48 | P a g e
VELOCIS EDUCATION C ++ MCQ MASTERY GUIDE
b) isalnum()
c) isdigit()
d) isblank()

Ans : d) isblank()

291. Which function is used to check whether a character is tab or space or whitespace control
code(\n,\r,etc.)?
a) isspace()
b) isalnum()
c) iscntrl()
d) isblank()

Ans : a) isspace()

292. Which function is used to check whether a character is tab or a control code?
a) isspace()
b) isalnum()
c) iscntrl()
d) isblank()

Ans : c) iscntrl()

293. Which function is used to check whether a character is printable on console?


a) isxdigit()
b) isprint()
c) iscntrl()
d) ispunct()

Ans : b) isprint()

294. Which function is used to check whether a character is hexadecimal?


a) isxdigit()
b) isprint()
c) iscntrl()
d) ispunct()

Ans : a) isxdigit()

295. Which function is used to check whether a character is punctuation mark?


a) isxdigit()
b) isprint()
c) iscntrl()
d) ispunct()

Ans : d) ispunct()

49 | P a g e
VELOCIS EDUCATION C ++ MCQ MASTERY GUIDE
296. Which types of input are accepted in toupper(c)?
a) char
b) char *
c) float
d) Both char and char *

Ans : a) char

297. What is the difference in the ASCII value of capital and non-capital of the same letter is?
a) 1
b) 16
c) 32
d) Depends with compiler

Ans : c) 32

298. Which character of pushback is guaranteed per file?


a) True
b) False
c) Depends on the compiler
d) Depends on the platform

Ans : a) True

299. How many characters for pushback is guaranteed per file while using ungetc(c, fp);?
a) Only 1 character
b) Characters within 1 word
c) Characters within 1st new-line
d) All characters upto NULL character

Ans : a) Only 1 character

300.ungetc() is used __________


a) to get a char
b) to get an int
c) to push a character back to file
d) nothing

ans : c) to push a character back to file

50 | P a g e

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy