Question 1
What are the four main principles of Object-Oriented Programming (OOP)?
Inheritance, Polymorphism, Abstraction, Composition
Inheritance, Polymorphism, Encapsulation, Abstraction
Inheritance, Encapsulation, Aggregation, Composition
Polymorphism, Encapsulation, Composition, Aggregation
Question 2
What is encapsulation in OOP?
The ability to create a new class based on an existing class
The process of combining data and functions into a single unit called a class
The ability to use the same interface for different data types
The process of hiding the implementation details and showing only the functionality
Question 3
What is polymorphism in OOP?
The ability of a class to inherit from multiple classes
The ability to redefine methods in derived classes
The ability to use the same interface for different data types
The ability to hide the implementation details of a class
Question 4
How to declare a function in C++ that returns an integer and takes two integer parameters?
int function(int, int);
int function(a, b);
int function(int a, int b);
int function();
Question 5
Which among the following is the correct syntax for defining a function in C++?
int function(int a, int b) { return a + b; }
int function(int a, int b); { return a + b; }
int function(int a, int b) return a + b;
int function(int a, int b) { return a + b }
Question 6
What is std::string_view used for in C++?
To provide a non-owning view of a string
To format strings
To print strings to the console
To modify strings
Question 7
How to format a string using std::format in C++?
std::format("{0} {1}", arg1, arg2)
std::format("{1} {2}", arg1, arg2)
std::format("{} {}", arg1, arg2)
std::format("{0} {}", arg1, arg2)
Question 8
Which function is used to print formatted output to the console in C++20?
std::cout
std::printf
std::print
std::puts
Question 9
What is the default return type of a function in C++ if not specified?
void
int
double
char
Question 10
How to pass a parameter by reference in C++?
void function(int* a)
void function(int a)
void function(int& a)
void function(int&* a)
There are 50 questions to complete.