7/10 -- Test Your C++ Knowledge with the CPP Questions Quiz! | Idyllic Quiz Results
Test Your C++ Knowledge with the CPP Questions Quiz!
Your Result:
Good
adaptablebastio
created on us.idyllic.app
70% correct (7/10)
Limited Offer!
Get Your FULL Personalized Result Analysis for just $5
Unlock deeper insights, compatibility guides, and ancient wisdom!
😍
Unlock Your Complete Results
Get a personalized, in-depth analysis of your quiz results sent directly to your inbox!
Your email is secure and will not be shared
Scroll down to see answers
created on us.idyllic.app
Scroll down to see answers
Rate this Quiz!
Share This Result
Comments
created on us.idyllic.app
New Quizzes & Global Leaderboard Daily
Quiz Leaderboard
Anonymous
10/4/2024
90%
adaptablebastio
6/20/2024
70%
Answers
1. Which of the following is a correct way to initialize a std::vector in C++?
std::vector<int> v = {1, 2, 3};
std::vector<int> v = 1, 2, 3;
std::vector<int> v(1, 2, 3);
std::vector<int> v(1, 2, 3, 4);
2. What is the output of the following code?
int main() {
int a = 10;
int b = 20;
swap(a, b);
cout << a << " " << b;
return 0;
}
10 20
20 10
Compiler error
Runtime error
3. Which C++ feature allows a function or an operator to be defined for multiple data types?
Polymorphism
Inheritance
Overloading
Encapsulation
4. What is the primary use of the 'std::unique_ptr' class in C++?
To ensure only one reference to a dynamically allocated object
To allow multiple references to a dynamically allocated object
To provide reference counting for dynamic objects
To create arrays of dynamic objects
5. Which keyword is used to prevent a method from being overridden in a derived class?
static
final
const
override
6. In C++, what is the purpose of the 'decltype' specifier?
To define a new type
To automatically deduce the type of an expression
To declare a variable constant
To delete a dynamically allocated object
7. What does the following code print?
#include <iostream>
void func(const int& x) {
std::cout << x << std::endl;
}
int main() {
int y = 10;
func(y);
return 0;
}
10
Compiler error
Garbage value
Runtime error
8. Which of the following is correct about virtual functions in C++?
They must be defined in the derived class.
They cannot have a return type.
They support runtime polymorphism.
They cannot be overridden in the derived class.
9. What is the use of the 'std::move' function in C++?
To copy an object
To move an object, enabling transfer of resources
To delete an object
To create a new object
10. Which of the following statements about 'templates' in C++ is true?
Templates allow functions and classes to operate with generic types.
Templates can only be used with classes, not functions.