In C++, what is a lambda function?
A. A function that takes no arguments and returns nothing
B. An anonymous function that can be used as an argument to other functions
C. A function that automatically adjusts its return type
D. None of the above
Select an option to see the answer and solution.
What is the purpose of the 'decltype' keyword in C++?
A. Determines the type of an expression or variable
B. Declares the type of a function parameter
C. Specifies the type of a function's return value
D. Returns the size of a data type
Select an option to see the answer and solution.
What is the correct way to declare a function that takes a pointer as an argument in C++?
A. returnType functionName(*type parameter)
B. returnType functionName(type parameter*)
C. returnType functionName(type ¶meter)
D. returnType functionName(type* parameter)
Select an option to see the answer and solution.
What will be the output of the following code: void display() { cout << "Hello"; } int main() { display(); return 0; } in C++?
A. Compilation error
B. 0
C. Hello
D. Undefined behavior
Select an option to see the answer and solution.
What will be the output of the following C++ code?
#include <iostream>
using namespace std;
int func (int a, int b)
{
cout << a;
cout << b;
return 0;
}
int main(void)
{
int(*ptr)(char, int);
ptr = func;
func(2, 3);
ptr(2, 3);
return 0;
}A. 2323
B. 232
C. 23
D. compile time error
Select an option to see the answer and solution.
If we start our function call with default arguments means, what will be proceeding arguments?
A. user argument
B. empty arguments
C. default arguments
D. user & empty arguments
Select an option to see the answer and solution.
Which of the following is the default return value of functions in C++?
Select an option to see the answer and solution.
What is an inline function?
A. A function that is expanded at each call during execution
B. A function that is called during compile time
C. A function that is not checked for syntax errors
D. A function that is not checked for semantic analysis
Select an option to see the answer and solution.
What will be the output of the following C++ code?
include <iostream>
using namespace std;
long factorial (long a)
{
if (a > 1)
return (a * factorial (a + 1));
else
return (1);
}
int main ()
{
long num = 3;
cout << num << "! = " << factorial ( num );
return 0;
}A. 6
B. 24
C. segmentation fault
D. compile time error
Select an option to see the answer and solution.
Identify the correct statement.
A. Namespace is used to group class, objects and functions
B. Namespace is used to mark the beginning of the program
C. A namespace is used to separate the class, objects
D. Namespace is used to mark the beginning & end of the program
Select an option to see the answer and solution.
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. header section
Select an option to see the answer and solution.
If an argument from the parameter list of a function is defined constant then . . . . . . . .
A. It can be modified inside the function
B. It cannot be modified inside the function
C. Error occurs
D. Segmentation fault
Select an option to see the answer and solution.
What will be the output of the following C++ code?
#include <iostream>
using namespace std;
void Funct();
int main()
{
try
{
Funct();
}
catch(double)
{
cerr << "caught a double type..." << endl;
}
return 0;
}
void Funct()
{
throw 3;
}A. caught a double type
B. compile time error
C. abnormal program termination
D. runtime error
Select an option to see the answer and solution.
What will be the output of the following C++ code?
#include <iostream>
using namespace std;
void Sum(int a, int b, int & c)
{
a = b + c;
b = a + c;
c = a + b;
}
int main()
{
int x = 2, y =3;
Sum(x, y, y);
cout << x << " " << y;
return 0;
}A. 2 3
B. 6 9
C. 2 15
D. compile time error
Select an option to see the answer and solution.
Identify the correct statement.
A. c++ does not have built-in interfaces
B. c++ does have built-in interfaces
C. c++ have no concept of interfaces
D. c++ does have built-in interfaces & classes
Select an option to see the answer and solution.
which of the following can be passed in function pointers?
A. variables
B. data types
C. functions
D. objects
Select an option to see the answer and solution.
Where should default parameters appear in a function prototype?
A. To the rightmost side of the parameter list
B. To the leftmost side of the parameter list
C. Anywhere inside the parameter list
D. Middle of the parameter list
Select an option to see the answer and solution.
What will be the output of the following C++ code?
#include <iostream>
#include <string>
using namespace std;
namespace A{
int var = 10;
}
namespace B{
int cout = 5;
}
int main()
{
using namespace B;
cout<<A::var;
}Select an option to see the answer and solution.
Which is more effective while calling the functions?
A. call by value
B. call by reference
C. call by pointer
D. call by object
Select an option to see the answer and solution.
What is similar to the interface in c++?
A. methods
B. instance of a class
C. pure abstract class
D. methods & instance of a class
Select an option to see the answer and solution.