Académique Documents
Professionnel Documents
Culture Documents
I Semester
MCQs
1. Wrapping data and its related functionality into a single entity is known as _____________
a) Abstraction
b) Encapsulation
c) Polymorphism
d) Modularity
Answer: b.
b) In Structures, members are private by default whereas in Classes they are public by default
Answer: a
Answer: a
4. Which concept allows you to reuse the written code?
a) Encapsulation
b) Abstraction
c) Inheritance
d) Polymorphism
Answer: c
a)
b)
int func(int);
int func(int);
c)
int func(float);
d)
int func();
int new_func();
Answer: c
a) A->B->C
b) A->B; A->C
c) A,B->C
d) B->A
Answer: c
Answer: b
8. C++ is ______________
Answer: d
Answer: b
10. Which of the following feature of OOPs is not used in the below code?
class A
int i;
public:
void print(){cout<<"hello"<<i;}
}
class B: public A
int j;
public:
a)Abstraction
b)Encapsulation
c)Inheritance
d)Polymorphism
Answer:d
set ii
1. Which of the following is the correct syntax of including a user defined header files in C++?
a) #include <userdefined.h>
b) #include <userdefined>
c) #include “userdefined”
d) #include [userdefined]
Answer: c
a) 7var_name
b) 7VARNAME
c) VAR_1234
d) $var_name
Answer: c
a) *
b) &
c) _
d) %
Answer: b
a) // comment
b) /* comment */
d) // comment */
Answer: c
Answer: a
Answer: b
b) cout.putline(ch)
c) write(ch)
d) printf(ch)
Answer: a
c) Set of characters that are used in the name of the main function of the program
Answer: a
a) \r
b) \n
c) \n\r
d) \c
Answer: a
a) Bjarne Stroustrup
b) Dennis Ritchie
c) Ken Thompson
d) Brian Kernighan
Answer: a
13. Which of the following is called insertion/put to operator?
a) <<
b) >>
c) >
d) <
Answer: a
a) <<
b) >>
c) >
d) <
Answer: b
15. A language which has the capability to generate new data types are called ________________
a) Extensible
b) Overloaded
c) Encapsulated
d) Reprehensible
Answer: a
a) >>
b) <<
c) <
d) >
Answer: b
a) Class
b) Member functions
c) Constructors
d) Destructors
Answer: c
a) Virtual functions
b) Operator functions
c) Constant functions
d) Static functions
Answer: a
Answer: d
5. Which of the following supports the concept that reusability is a desirable feature of a language?
Answer: d
a) Function overloading
b) Operator overloading
c) Templates
Answer: d
a) I only
b) II only
c) Both I and II
d) Neither I nor II
Answer: d
a) Multiple
b) Multilevel
c) Distributive
d) Hierarchical
Answer: c
c) It is not allowed
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
Answer: a
Which members are inherited but are not accessible in any case?
a) Private
b) Public
c) Protected
Answer: a
FUNDAMENTALS
A) Martin Richards
B) Bijarne Stroustrup
C) Dennis Ritche
D) Ken Thompson
A) 9
B) 8
C) 7
D) 6
3. C can be used on
A) 17
B) 14
C) 15
D) 16
help of
A) An Editor
B) A complier
C) An operating system
6. Array is
A) [ ]
B) { }
C) ( )
A) Loop
B) If condition
C) Function
D) Structure
B) 3
C) 0
D) 2
A) Value of variable
B) Address of variable
D) Always null
Answers:
1. C) Dennis Ritche
2. B) 8
4. C) 15
5. B) A complier
7. C) ( )
8. A) Loop
9. D) 2
FUNDAMENTALS II
A) >>
B) >
C) <<
D) <
2. State True or False.
i) A satic function can have access to only other static members (functions or variables) declared in the
same class.
ii) A static member function can be called using the class name (instead of its objects)
A) True, True
B) True, False
C) False, True
D) False, False
3. Which of the following condition is true for an object used as a function argument?
A) Only i
B) Only ii
C) Both i and ii
D) None of them
4. …………… enable us to hide, inside the object, both the data fields and the methods that act on that
data.
A) Encapsulation
B) Polymorphism
C) Inheritance
D) Overloading
A) It is not in the scope of the class to which it has been declared as friend.
B) It can invoke like a normal function without the help of any object.
6. The dereferencing operator ………….. is used to access a member when we use pointers to both the
object and the member.
A) ->*
B) .*
A) Subclass
B) Abstract Class
C) Meta Class
D) Object Class
8. The dereferencing operator ……… is used when the object itself is used width in the member pointer.
A) ->*
B) .*
A) Paramless constructor
B) No parameter constructor
C) Default constructor
D) Argumentless constructor
10. Automatic initialization of object is carried out using a special member function called …………
A) Friend
B) Casting
C) Reference Parameter
D) Constructor
ii) They are invoked automatically when the objects are created.
12. A ……………. takes a reference to an object of the same class as itself as an argument.
A) Reference constructor
B) Copy Constructor
C) Self Constructor
i) A destructor never takes any argument nor does it return any value.
A) True, True
B) True, False
C) False, True
D) False, False
C) i, iii, iv only
15. …………. Is the process of creating new classes, called derived classes from existing classes called base
class.
A) Inheritance
B) Encapsulation
C) Polymorphism
D) Overloading
ii) The binary operator such as +, -, * and must explicitly return a value.
A) True, True
B) True, False
C) False, True
D) False, False
A) cputs ()
B) put ()
C) gets ()
D) tputs ()
18. Which of the following condition (s) should satisfy the casting operator.
i) Long double ii) Double iii) Float iv) Long v) Int vi) Char
A) 1-2-3-4-5-6
B) 1-3-2-4-5-6
C) 1-2-3-5-4-6
D) 1-2-4-3-5-6
A) floodfill ()
B) setcolor()
C) setfillstyle()
D) fillstyle ()
ANSWERS:
1. C) <<
2. B) True, False
3. C) Both i and ii
4. A) Encapsulation
6. A) ->*
7. C) Meta Class
8. B) .*
9. C) Default constructor
10. D) Constructor
15. A) Inheritance
17. A) cputs ()
19. A) 1-2-3-4-5-6
20. C) setfillstyle()
1. C++ provides a special ………………… called the constructor, which enables an object to initialize itself
when it is created.
A) friend function
B) member function
C) public function
D) private function
A) variable
B) object
C) function
D) name
A) define variables
B) allocate variables
C) initialize variables
D) initialize object
A) default constructor
B) parameterized constructor
C) implicit constructor
D) null constructor
5. Constructors cannot be inherited, through a derived class can call the ………………. constructor.
A) base class
B) derived class
C) void class
D) default class
6. State whether the following statements about the constructor are True or False.
ii) constructors are invoked automatically when the objects are created.
A) True, True
B) True, False
C) False, True
D) False, False
7. The constructors that can take arguments are called …………… constructors.
A) default constructor
B) parameterized constructor
C) implicit constructor
D) argument constructor
8. When an object is created and initialized at the same time, a ………………. gets called.
A) default constructor
B) parameterized constructor
C) implicit constructor
D) copy constructor
9. In C++, ……………………. creates objects, even through it was not defined in the class.
A) default constructor
B) parameterized constructor
C) implicit constructor
D) copy constructor
10. …………….. constructor will not do anything and defined just to satisfy the compiler
A) default
B) parameterized
C) implicit
D) copy
11. The ………………… constructor can be called with either one argument or no arguments.
A) default
B) default argument
C) implicit
D) copy
12. A ………………….. is used to declare and initialize an object from another object.
A) default constructor
C) implicit constructor
D) copy constructor
13. A ……………. takes a reference to an object of the same class as itself as an argument.
A) default constructor
C) implicit constructor
D) copy constructor
14. Destructor is a member function whose name is same as the class name but is preceded by a ………..
A) tilde
B) hash
C) dot
D) dollor
15. A destructor is used to destroy the objects that have been created by a ………………..
A) object
B) class
C) function
D) constructor
16. Whenever const objects try to invoke non-const member functions, the compiler …………………
B) return null
C) generate error
D) return no value
17. Allocation of memory to objects at the time of their construction is known as ……………. of objects.
B) dynamic construction
C) initial construction
D) static construction
A) copy process
B) copy registration
C) copy initialization
D) initialization process
19. ……………….. provides the flexibility of using different format of data at runtime depending upon the
situation.
A) dynamic initialization
C) static initialization
D) variable initialization
A) class
B) object
C) function
D) variable
ANSWERS
1. B) member function
2. D) name
3. C) initialize variables
4. A) default constructor
5. A) base class
6. C) False, True
7. B) parameterized constructor
8. D) copy constructor
9. C) implicit constructor
10. C) implicit
14. A) tilde
15. D) constructor
20. B) object
TOKENS EXPRESSIONS AND CONTROL STURCTURE
1. In C++, we can give several meanings to an operator, depending upon the types of arguments used,
which was known as …………..
A) Operator variable
B) Operator overloading
C) Operator loading
D) Operator manipulation
A) i and ii only
C) i and iv only
A) : :
B) : : *
C) _>*
D) . *
A) pointer-to-member
B) memory release
C) scope resolution
D) line feed
5. A major application of the ………………… operator is in the classes to identify the class to which a
member function belongs.
A) pointer-to-member
B) memory release
C) scope resolution
D) line feed
6. ……………….. operator is used to access a member using a pointer to the object and a pointer to that
member.
A) : :
B) : : *
C) _>*
D) . *
A) : :
B) : : *
C) _>*
D) . *
8. The ………………. operator allocates sufficient memory to hold a data object type data type and returns
the address of the object.
A) malloc()
B) calloc()
C) new
D) free()
A) delete all p;
B) delete array p;
C) delete * p;
D) delete[ ] p;
10. The ……………… operator automatically returns the correct pointer type, so that there is no need to
use a type cast.
A) new
B) delete
C) malloc()
D) setw
11. The …………….. manipulator is used in an output statement which causes a linefeed to be inserted.
A) setw
B) delete
C) endl
D) symbol
12. Which of the following is/are the new cast operators used in C++.
13. A/An …………………. is a combination of operator, constants and variables arranged as per the rules of
the language.
A) token
B) expression
C) structure
D) none
A) Relational expressions
B) Float expressions
C) Logical expressions
D) Bitwise expressions
16. ……………… combine to or more relational expressions and produces bool type results.
A) Relational expressions
B) Float expressions
C) Logical expressions
D) Bitwise expressions
17. The ………………… is an entry-enrolled loop and is used when an action is to be repeated for
predetermined number of times.
A) while
B) for
C) do-while
D) switch
18. The ………………….. is an exit-enrolled loop where the control is transferred back to a particular point
in the program.
A) while
B) for
C) do-while
D) switch
possible points.
A) while
B) for
C) do-while
D) switch
20. The operator ………………… is known as compound assignment or short-hand assignment operator.
A) =
B) = =
C) += =
D) +=
ANSWERS
1. B) Operator overloading
3. A) : :
4. C) scope resolution
5. C) scope resolution
6. C) _>*
7. B) : : *
8. C) new
9. D) delete[ ] p;
10. A) new
11. C) endl
13. B) expression
17. B) for
18. C) do-while
19. D) switch
20. D) +=
CLASSES AND OBJECTS
1. In C++, the declaration of functions and variables are collectively called …….
A) class members
B) function members
C) object members
D) member variables
2. The keywords private and public used in C++ are known as ………….
A) keyword labels
B) visibility labels
C) declaration labels
D) display labels
3. The variables declared inside the class are known as data members and functions are known as
………….
A) data functions
B) inline functions
C) member functions
D) member variables
4. Only the …………………. can have access to the private members and private functions.
A) data functions
B) inline functions
C) member functions
D) member variables
5. The binding of data and functions together into a single class-type variable is referred to as …………..
A) encapsulation
B)
C)
D)
6. Which of the following statements about member functions are True or False.
i) A member function can call another member function directly with using the dot operator.
ii) Member function can access the private data of the class.
A) i-True, ii-True
B) i-False, ii-True
C) i-True, ii-False
D) i-True, ii-True
A) data function
B) inline function
C) member function
D) member variable
8. A member function can be called by using its name inside another function of the same class, which is
known as ………… of member function.
A) sub function
B) sub member
C) nesting
D) sibling
9. A ………………. member function can only be called by another function that is member of it’s class.
A) friend
B) static
C) public
D) private
10. ……………….. member variable is initialized to zero when the first object of its class is created where
no other initialization is permitted.
A) friend
B) static
C) public
D) private
11. State whether the following statements are True or False about the characteristics of static data
members.
i) Only one copy of static member is created for the entire class and is shared by all the objects of that
class, no matter how many objects are created.
ii) Static member variable is visible only within the class, but its lifetime is the entire program.
A) i-True, ii-True
B) i-False, ii-True
C) i-True, ii-False
D) i-True, ii-True
12. Static variables are associated with the class itself rather than with any class object, they are also
known as …………….
A) class variables
B) object variables
C) function variables
D) internal variables
13. Static variables are like ………………… as they are declared in a class declaration and defined in the
source file.
14. A …………….. can have access to only other static members declared in the same class.
D) friend function
15. A static member function can be called using the ………………… instead of its objects.
A) variable name
B) function name
C) Class name
D) object name
16. While using an object as a function argument, a copy of the entire object is passed to the function in
………….. method.
A) pass-by-value
B) pass-by-reference
C) pass-by-variable
D) pass-by-function
17. A ……………………., although not a member function, has full access rights to the private members of
the class.
D) friend function
18. ……………. can be invoked like a normal function without the help of any object.
D) friend function
19. A ………….. can only be called by another function that is member of its class.
D) friend function
20. If a member function does not alter any data in the class, that may be declared as ………………..
D) friend function
ANSWERS
1. A) class members
2. B) visibility labels
3. C) member functions
4. C) member functions
5. A) encapsulation
6. B) i-False, ii-True
7. B) inline function
8. C) nesting
9. D) private
10. B) static
16. A) pass-by-value
C) Size operator(sizeof)
D) Conditional operator(?:)
A) member functions
B) Operator functions
C) non-static functions
D) friend functions
A) run time
B) initial time
C) compile time
D) completion time
4) We can overload almost all the C++ operators except the following.
5) Which of the following is the correct order involves in the process of operator overloading.
ii) Create a class that defines the data type that is to be used in the overloading operation.
iii) Declare the operator function op() in the public part of the class.
6) State whether the following statements are True or False for overloading operators.
A) True, True
B) True, False
C) False, True
D) False, False
A) i and ii only
D) i and iv only
8) …………… overloaded by means of a member function, take no explicit arguments and return no
explicit values.
A) Unary operators
B) Binary operators
C) Arithmetic operators
D) Function operator
9) ……………. overloaded through a member function take one explicit argument and those which are
overloaded through a friend function take two explicit arguments.
A) Unary operators
B) Binary operators
C) Arithmetic operators
D) Function operator
10) When using ………………., overloaded through a member function, the left hand operand must be an
object of the relevant class.
A) Unary operators
B) Binary operators
C) Arithmetic operators
D) Function operator
11) Operator overloading is done with the help of a special function called ……………, which describes the
special task of an operator.
A) overloading function
C) detail function
D) operator function
12) The compiler does not support automatic type conversions for the ………….. data type.
A) basic
B) user defined
C) class
D) automatic
13) The casting operator function should satisfy which of the following conditions.
A) i and ii only
C) i, iii only
14) The conversion from a class to any other type or any other class should make use of a ………….. in the
source class.
A) casting operator
B) constructor
C) not applicable
D) operator function
15) To perform the conversion from any other data type or class to a class type, a ………….. should be
used in the destination class.
A) casting operator
B) constructor
C) not applicable
D) operator function
16) The general form of an overloaded casting operator function usually referred to as a ……………..
A) casting function
B) operator function
C) conversion function
D) overloaded function
17) Operator overloading provides a flexible option for the creation of new …………….. for most of the
C++ operations.
A) class
B) function
C) object
D) definitions
18) In the case of …………….. function, arguments may be passed either by value or by reference.
A) private
B) friend
C) member
D) public
ANSWERS
2) B) Operator functions
3) C) compile time
6) B) True, False
8) A) Unary operators
9) B) Binary operators
15) B) constructor
17) D) definitions
18) B) friend