FUNCTIONS QNA
1 A ………………….. is used to declare and initialize an object from
another object.
A default constructor
B default argument constructor
C implicit constructor
D copy constructor
Answer: Option [D]
2 A ……………. takes a reference to an object of the same class as
itself as an argument.
A default constructor
B default argument constructor
C implicit constructor
D copy constructor
Answer: Option [D]
Advertisement
3 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
Answer: Option [A]
4 A destructor is used to destroy the objects that have been created
by a ………………..
A object
B class
C function
D constructor
Answer: Option [D]
5 Whenever const objects try to invoke non-const member
functions, the compiler …………………
A return zero value
B return null
C generate error
D return no value
Answer: Option [C]
6 Allocation of memory to objects at the time of their construction is
known as ……………. of objects.
A run time construction
B dynamic construction
C initial construction
D static construction
Answer: Option [B]
7 The process of initializing through a copy constructor is known as
……………
A copy process
B copy registration
C copy initialization
D initialization process
Answer: Option [C]
8 ……………….. provides the flexibility of using different format of
data at runtime depending upon the situation.
A dynamic initialization
B run time initialization
C static initialization
D variable initialization
Answer: Option [A]
9 An ………………….. with a constructor or destructor cannot be used
as a member or a union.
A class
B object
C function
D None of these above
Answer: Option [B]
10 In a program, If there exists a function template with two
parameters and normal function say void add(int , int), so add(3,4)
will _____________________ .
A Invoke function template body as it is generic one
B Invokes normal function as it exactly matches with its prototype
C Not be called and Compiler issues warning
D Not be called and Compiler issues ambiguity in calling add()
Answer: Option [B]
11 Assigning one or more function body to the same name is called
____________ .
A Function Overriding
B Function Overloading
C Both a and b
D None of the above
Answer: Option [B]
12 Default values for a function are specified when ____ .
A function is defined
B function is declared
C Both a and b
D None of these
Answer: Option [B]
13 If an argument to a function is declared as const, then _______ .
A function can modify the argument.
B Function can’t modify the argument.
C const argument to a function is not possible.
D None of these
Answer: Option [B]
14 Default return type of functions in CPP is ____ .
A void
B long
C char
D Int
Answer: Option [D]
15 Which of the following best defines the syntax for template
function ?
A Template
B Template return_type Function_Name(Parameters)
C Both a and b
D None of these
Answer: Option [C]
16 Which of the following function / types of function cannot have
default parameters?
A Member function of class
B Main()
C Member function of structure
D Both B and C
Answer: Option [B]
17 Correct way to declare pure virtual function in a C++ class is
A Virtual void foo() =0 ;
B Void virtual foo()= { 0 }
C Virtual void foo() {} = 0;
D None of the above
Answer: Option [A]
18 What is the scope of the variable declared in the user defined
function?
A Whole program
B Only inside the {} block
C The main function
D None of the above
Answer: Option [B]
19 Which of the following in Object Oriented Programming is
supported by Function overloading and default arguments features
of C++.
A Inheritance
B Polymorphism
C Encapsulation
D None of these
Answer: Option [B]
20 Which of the following statement is correct?
A Only one parameter of a function can be a default parameter.
B Minimum one parameter of a function must be a default
parameter.
C All the parameters of a function can be default parameters.
D No parameter of a function can be default.
Answer: Option [C]
21 Which is used to keep the call by reference value as intact?
A static
B const
C absolute
D none of the mentioned
Answer: Option [B]
22 By default how the value are passed in c++?
A call by value
B call by reference
C call by pointer
D none of the mentioned
Answer: Option [A]
Advertisement
23 What will happen when we use void in argument passing?
A It will not return value to its caller
B It will return value to its caller
C both a & b are correct
D none of the mentioned
Answer: Option [A]
24 How many types of returning values are present in c++?
A1
B2
C3
D4
Answer: Option [C]
25 What will you use if you are not intended to get a return value?
A static
B const
C volatile
D void
Answer: Option [B]
26 Where does the return statement returns the execution of the
program?
A main function
B caller function
C same function
D none of the mentioned
Answer: Option [B]
27 When will we use the function overloading?
A same function name but different number of arguments
B different function name but same number of arguments
C same function name but same number of arguments
D different function name but different number of arguments
Answer: Option [A]
28 Overloaded functions are
A Very long functions that can hardly run
B One function containing another one or more functions inside it
C Two or more functions with the same name but different number
of parameters or type
D variable initialization
Answer: Option [C]
29 What will happen while using pass by reference
A The values of those variables are passed to the function so that it
can manipulate them
B The location of variable in memory is passed to the function so
that it can use the same memory area for its processing
C The function declaration should contain ampersand (& in its type
declaration)
D All of the mentioned
Answer: Option [B]
30 What are mandatory parts in function declaration?
A return type,function name
B return type,function name,parameters
C both a and b
D none of the mentioned
Answer: Option [A]
31 which of the following is used to terminate the function
declaration?
A:
B.
C;
D none of the mentioned
Answer: Option [C]
32 How many max number of arguments can present in function in
c99 compiler?
A 99
B 90
C 102
D 127
Answer: Option [D]
33 Which is more effective while calling the functions?
A call by value
B call by reference
C call by pointer
D none of the mentioned
Answer: Option [B]
34 In C++ code , variables can be passed to a function by
A Pass by value
B Pass by reference
C Pass by pointer
D All the above
Answer: Option [D]
35 Constant function in C++ can be declared as
A void display()
B void display() const
C const void display()
D void const display()
Answer: Option [B]
36 True and false statements about inline function in given C++
code example is/are
(I)Static function of a class can be called by class name using scope
resolution operator i.e. : :
(II)Static function can receive both static and non-static data
members of a class
(III)Static function is not the part of an object of a class
A I and II
B I only
C I and III
D I, II and III
Answer: Option [C]
37 Which of the following functions are provided by compiler by
default if we don’t write in a C++ class?
A Copy constructor
B Assignment
C Constructor
D All the above
Answer: Option [B]
38 When our function doesn’t need to return anything means what
we will as parameter in function?
A void
B blank space
C both a & b
D none of the mentioned
Answer: Option [B]
39 Which function can be called without using an object of a class in
C++
A Static function
B Inline function
C Friend function
D constant function
Answer: Option [A]
40 Which function can be called without using an object of a class in
C++
A Virtual function
B Inline function
C Static function
D constant function
Answer: Option [C]
41 To which does the function pointer point to?
A variable
B constants
C function
D absolute variablesd
Answer: Option [C]
42 Variable that are listed in function's calls are called
A Actual parameter
B Declared parameter
C Passed parameter
D None of them
Answer: Option [A]
Advertisement
43 A programmer can create custom header files that must be end
with
A h extension
B l extension
C ios extension
D a extension
Answer: Option [A]
44 Unary scope resolution operator is denoted by
A!!
B%%
C:
D::
Answer: Option [D]
45 To make large programs more manageable programmers
modularize them into subprograms that are called
A Operators
B Classes
C Functions
D None of them
Answer: Option [C]
46 Maths function acos (x) stands for
A Inverse Cosine of x
B Inverse Sine of x
C Inverse Tangent of x
D Floor of x
Answer: Option [A]