0% found this document useful (0 votes)
22 views3 pages

OOPM QuizA1

Uploaded by

Jaya Mishra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views3 pages

OOPM QuizA1

Uploaded by

Jaya Mishra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

OOPM MCQs Question

Skill Assessment -I
Batch- A1
Sem- III A Total Marks-10

1. Which of the following is the correct definition of encapsulation in C++?

a) Hiding the internal state of an object


b) Inheriting properties from another class
c) Defining the class interface
d) Assigning values to objects

2. What is the term for a class that is designed to be a base for other classes and cannot be
instantiated in C++?

a) Friend class
b) Abstract class
c) Static class
d) Virtual class

3. Which access specifier allows members of a class to be accessible only within the class itself
and its derived classes?

a) Public
b) Protected
c) Private
d) Static

4. Which of the following is used to declare a pure virtual function in C++?

a) virtual void function();


b) virtual void function() = 0;
c) void virtual function() = 0;
d) void function() = virtual 0;

5. Which of the following is NOT a feature of C++ constructors?

a) They have the same name as the class


b) They do not have a return type
c) They can be overloaded
d) They are inherited by derived classes

6. In C++, what will be the output of the following code?

class A {
public:
void display() {
cout << "Class A";
}
};
class B : public A {
public:
void display() {
cout << "Class B";
}
};
int main() {
A* ptr;
B obj;
ptr = &obj;
ptr->display();
}

a) Class A
b) Class B
c) Compile-time error
d) Runtime error

7. Which of the following is true about multiple inheritance in C++?

a) It is not supported in C++


b) A derived class can inherit from more than one base class
c) It causes an error during compilation
d) Only one base class can be inherited

8. What is the correct syntax for declaring a destructor in C++?

a) ~class_name();
b) class_name::~();
c) void class_name::~();
d) destructor class_name();

9. What is the result of calling a non-virtual function from a derived class object using a base class
pointer in C++?

a) The base class function is called


b) The derived class function is called
c) It results in an error
d) The function does not get called

10. In C++, which of the following is used to allocate memory for an array of objects dynamically?

a) new
b) new[]
c) malloc[]
d) calloc[]

11. What is the purpose of a virtual destructor in C++?

a) To destroy objects dynamically created


b) To prevent memory leaks when deleting derived class objects through base class pointers
c) To allow multiple destructors
d) To create a default destructor for derived classes

12. Which of the following operators is used to call a member function of a class through a pointer to an
object in C++?

a) .
b) ->
c) ::
d) *

13. What is the default visibility of members of a class in C++?


a) Public
b) Private
c) Protected
d) Static

14. Which of the following statements is true about function overloading in C++?

a) Functions must have different return types


b) Functions must have different names
c) Functions must have different numbers or types of parameters
d) Function overloading is not allowed in C++

15. Which of the following types of inheritance is allowed in C++?

a) Hierarchical inheritance
b) Multiple inheritance
c) Hybrid inheritance
d) All of the above

16. Which type of polymorphism is demonstrated by function overloading in C++?

a) Compile-time polymorphism
b) Runtime polymorphism
c) Static polymorphism
d) Dynamic polymorphism

17. Which of the following is the correct way to declare an abstract class in C++?

a) class Abstract { void function() = 0; };


b) class Abstract { virtual void function() = 0; };
c) class Abstract { abstract void function(); };
d) class Abstract { public: virtual void function() = 0; };

18. In C++, which of the following is NOT a valid data type for a member of a class?

a) int
b) float
c) double
d) function

19. In C++, what is the purpose of a copy constructor?


a) To initialize an object with default values
b) To create a new object from an existing object
c) To initialize an object with dynamic memory
d) To perform deep copying of the object’s member variables

20. Which of the following is used to access a static member of a class in C++?

a) .
b) ::
c) ->
d) []

You might also like