
Mastering C++ Concepts
Authored by CHINMAYEE JADHAV
Computers
University
Used 1+ times

AI Actions
Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...
Content View
Student View
20 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the purpose of file handling in C++?
To create graphical user interfaces.
To manage memory allocation in C++.
The purpose of file handling in C++ is to enable reading from and writing to files for data persistence.
To improve the speed of program execution.
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Explain the difference between ifstream and ofstream in C++.
ifstream is for writing to files, while ofstream is for reading from files.
ifstream is for reading from files, while ofstream is for writing to files.
Both ifstream and ofstream are used for reading files only.
ifstream and ofstream are the same and can be used interchangeably.
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
How do you open a file for reading in C++?
std::ifstream file = new ifstream("filename.txt");
std::ifstream file.open("filename.txt");
std::ifstream file;
std::ifstream file("filename.txt");
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is operator overloading in C++?
Operator overloading is a method to increase the speed of C++ programs.
Operator overloading is a feature that allows the use of C++ keywords as variable names.
Operator overloading is a way to create new operators in C++.
Operator overloading is a feature in C++ that allows operators to be redefined and used with user-defined types.
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Provide an example of overloading the '+' operator for a class.
class Vector: def __init__(self, x, y): self.x = x self.y = y def __add__(self, other): return Vector(self.x + other.x, self.y + other.y) v1 = Vector(1, 2) v2 = Vector(3, 4) v3 = v1 + v2 # v3 is now Vector(4, 6)
class Vector: def __init__(self, x): self.x = x def __add__(self, other): return self.x + other
class Vector: def __init__(self, x, y): self.x = x self.y = y def add(self, other): return Vector(self.x + other.x, self.y + other.y)
class Vector: def __init__(self, x, y): self.x = x self.y = y def __add__(self, other): return (self.x + other.x, self.y + other.y)
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What are the advantages of using STL in C++?
STL is not compatible with object-oriented programming.
Advantages of using STL include code reusability, performance, flexibility, ease of use, and support for generic programming.
STL increases the complexity of code without benefits.
STL is only useful for small projects.
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Name three types of STL containers and their uses.
vector, list, map
array, set, queue
hashmap, tree, graph
stack, deque, tuple
Access all questions and much more by creating a free account
Create resources
Host any resource
Get auto-graded reports

Continue with Google

Continue with Email

Continue with Classlink

Continue with Clever
or continue with

Microsoft
%20(1).png)
Apple
Others
Already have an account?