OO1
What is the purpose of a constructor in C++?
To initialize an object's data members
To declare variables
To perform mathematical operations
To define member functions
What is the output of the following code snippet?\n\n#include \nusing namespace std;\n\nint main() {\n int x = 5;\n cout << x++ << endl;\n cout << ++x << endl;\n return 0;\n}
5\n7
6\n7
5\n6
6\n6
Which of the following is NOT a principle of object-oriented programming?
Encapsulation
Inheritance
Polymorphism
Abstraction
Iteration
What is the output of the following code snippet?\n\n#include \nusing namespace std;\n\nint main() {\n int arr[5] = {1, 2, 3, 4, 5};\n cout << arr[3] << endl;\n return 0;\n}
4
3
5
2
Which of the following is true about virtual functions in C++?
They are used for achieving runtime polymorphism
They can be overridden in derived classes
They are declared using the 'virtual' keyword
They are only applicable to member functions
What is the correct way to define a constant in C++?
Const int MAX_VALUE = 100;
Int const MAX_VALUE = 100;
MAX_VALUE = 100;
Int MAX_VALUE = 100; const
Which of the following is NOT a type of inheritance in C++?
Single Inheritance
Multiple Inheritance
Hierarchical Inheritance
Dynamic Inheritance
Multilevel Inheritance
What is the output of the following code snippet?\n\n#include \nusing namespace std;\n\nint main() {\n int x = 10;\n if (x > 5) {\n cout << \
Hello
World
HelloWorld
No output
What is the purpose of the 'new' operator in C++?
To dynamically allocate memory for an object
To delete an object from memory
To create a new instance of a class
To initialize an object's data members
What is the output of the following code snippet?\n\n#include \nusing namespace std;\n\nint main() {\n int x = 5;\n int y = 2;\n cout << x / y << endl;\n return 0;\n}
2
2.5
2.0
2.25
Which of the following is true about static member variables in C++?
They are shared by all instances of a class
They can be accessed without creating an object
They are initialized to zero by default
They can be modified by any member function
What is the difference between 'public' and 'private' access specifiers in C++?
Public members can be accessed from outside the class, while private members can only be accessed within the class.
Public members can only be accessed within the class, while private members can be accessed from outside the class.
Public members have higher visibility than private members.
Private members have higher visibility than public members.
What is the output of the following code snippet?\n\n#include \nusing namespace std;\n\nint main() {\n int x = 5;\n int y = 2;\n cout << x % y << endl;\n return 0;\n}
1
2
0.5
0
Which of the following is NOT a valid way to initialize an object in C++?
Object obj;
Object obj = new Object();
Object obj();
Object obj = Object();
Object* obj = new Object();
What is the purpose of the 'virtual' keyword in C++?
To enable polymorphic behavior and late binding in derived classes.
To restrict access to class members.
To define a constant value.
To declare a pure virtual function.
What is the output of the following code snippet?\n\n#include \nusing namespace std;\n\nint main() {\n int x = 5;\n int y = 2;\n cout << (x > y ? x : y) << endl;\n return 0;\n}
5
2
True
False
Which of the following is NOT a valid way to access a member function of a class in C++?
Object.memberFunction();
Object->memberFunction();
ClassName::memberFunction();
ClassName.memberFunction();
ClassName* obj = new ClassName();\nobj->memberFunction();
What is the purpose of the 'this' pointer in C++?
To refer to the current object within a member function.
To allocate memory for an object on the heap.
To access static member variables.
To define a constant value.
What is the output of the following code snippet?\n\n#include \nusing namespace std;\n\nint main() {\n int arr[] = {1, 2, 3, 4, 5};\n cout << sizeof(arr) / sizeof(arr[0]) << endl;\n return 0;\n}
5
4
20
Sizeof(arr)
Which of the following is true about function overloading in C++?
Function overloading allows multiple functions with the same name but different parameters.
Function overloading allows multiple functions with the same name and same parameters.
Function overloading is a form of polymorphism.
Function overloading can only be applied to member functions.
Function overloading is determined at compile-time based on the number and types of arguments.
What is the purpose of the 'delete' operator in C++?
To deallocate memory that was previously allocated using the 'new' operator.
To delete an object from memory.
To remove a member function from a class.
To remove a file from the file system.
What is the output of the following code snippet?\n\n#include \nusing namespace std;\n\nint main() {\n int x = 5;\n int y = 2;\n cout << (x > y) << endl;\n return 0;\n}
1
2
True
False
Which of the following is NOT a valid way to declare a constant in C++?
Const int x = 5;
#define x 5
Enum {x = 5};
Constexpr int x = 5;
Const int* const ptr = &x;
What is the purpose of the 'static' keyword in C++?
To create class-level variables or functions that are shared among all instances of the class.
To restrict access to class members.
To define a constant value.
To allocate memory for an object on the heap.
What is the output of the following code snippet?\n\n#include \nusing namespace std;\n\nint main() {\n int x = 5;\n int y = 2;\n cout << (x < y ? x : y) << endl;\n return 0;\n}
2
5
True
False
What is the purpose of the 'cin' object in C++?
To read input from the user
To display output on the screen
To perform mathematical calculations
To declare variables
Which of the following is a valid way to initialize a string variable in C++?
String name = \
String name(\
String name = {'J', 'o', 'h', 'n'};
String name();
What is the output of the following code snippet?\n\n#include \nusing namespace std;\n\nint main() {\n int x = 5;\n int y = 3;\n cout << (x > y) << endl;\n return 0;\n}
1
0
True
False
Which of the following is NOT a valid way to declare and initialize an array in C++?
Int arr[5] = {1, 2, 3, 4, 5};
Int arr[] = {1, 2, 3, 4, 5};
Int arr[5] = {1};
Int arr[5];
Int arr[5] = {};
What is the purpose of the 'break' statement in C++?
To exit a loop or switch statement
To skip the current iteration of a loop
To jump to a specific label in the code
To terminate the program
What is the purpose of encapsulation in object-oriented programming?
To hide implementation details
To improve code reusability
To enable polymorphism
To facilitate inheritance
Which of the following is NOT a pillar of object-oriented programming?
Inheritance
Polymorphism
Abstraction
Procedural programming
Encapsulation
What is the output of the following code snippet?\n\n#include \nusing namespace std;\n\nint main() {\n int x = 10;\n int y = 5;\n cout << (x > y ? \
Which keyword is used to create an object in object-oriented programming?
New
Create
Instantiate
Allocate
What is the purpose of inheritance in object-oriented programming?
To create a hierarchy of classes
To hide implementation details
To enable code reusability
To achieve polymorphism
What is the difference between an abstract class and an interface in C++?
An abstract class can have implementation details, while an interface cannot.
An abstract class can be instantiated, while an interface cannot.
An abstract class can inherit multiple classes, while an interface cannot.
An abstract class can only have pure virtual functions, while an interface can have both pure virtual and non-virtual functions.
Which of the following statements about pure virtual functions in C++ is correct?
A class with at least one pure virtual function is considered an abstract class.
Pure virtual functions must be implemented in the derived classes.
Pure virtual functions can have a default implementation.
Pure virtual functions cannot be called directly.
What is the purpose of a destructor in C++?
To release resources and perform cleanup tasks before an object is destroyed.
To initialize an object when it is created.
To define the behavior of an object when it is copied.
To define the behavior of an object when it is assigned to another object.
Which of the following is true about function overriding in C++?
Function overriding occurs when a derived class provides a different implementation of a function already defined in the base class.
The return type of the overriding function must be the same as the return type of the overridden function.
The access specifier of the overriding function must be the same or less restrictive than the access specifier of the overridden function.
Function overriding can only occur between classes in the same inheritance hierarchy.
What is the purpose of a virtual destructor in C++?
To ensure that the destructor of the most derived class is called when deleting an object through a pointer to the base class.
To allow dynamic binding of member functions at runtime.
To prevent memory leaks in polymorphic classes.
To enable multiple inheritance in C++.
{"name":"OO1", "url":"https://www.quiz-maker.com/QPREVIEW","txt":"What is the purpose of a constructor in C++?, Which of the following is NOT a fundamental data type in C++?, What is the output of the following code snippet?\\n\\n#include \\nusing namespace std;\\n\\nint main() {\\n int x = 5;\\n cout << x++ << endl;\\n cout << ++x << endl;\\n return 0;\\n}","img":"https://www.quiz-maker.com/3012/images/ogquiz.png"}
More Quizzes
How Well Do You know The Original Mary Poppins?
1050
XHMIKH KINHTIKH
630
Which instrument part would you play in concert band?
940
Intelligence Test (Erudite)
210
Wellness Questionare
10510
How well do you know Lattice?
11619
Snow Falling
10517
100
Machine Learning & A.I.
8426
Web aplikacije u Javi
432234
What Type Of Magical Being Are You?
320
Quiz Meme by Augusto
630