Here are 15 multiple choice questions at the university level about C++
and object-oriented programming (OOP):
C++
1. What is the difference between a value type and a reference type in C++?
o (A) A value type is copied when it is passed to a function, while a reference type is not.
o (B) A value type can be null, while a reference type cannot.
o (C) A value type can be assigned to another value type, while a reference type cannot.
o (D) All of the above.
2. What is the purpose of the using keyword in C++?
o (A) To import a namespace into the current namespace.
o (B) To create a new alias for a type or function.
o (C) To forward declare a class or function.
o (D) All of the above.
3. What is the difference between a static member function and a non- static member function in C++?
o (A) A static member function can be called without creating an instance of the class, while a non-static member function cannot.
o (B) A static member function does not have access to the non-static members of the class, while a non-static member function does.
o (C) A static member function is typically used for utility functions, while a non-static member function is typically used for operations specific to the class.
o (D) All of the above.
OOP
4. What are the four pillars of object-oriented programming?
o (A) Abstraction, encapsulation, inheritance, and polymorphism.
o (B) Classes, objects, methods, and fields.
o (C) Public, private, protected, and default access modifiers.
o (D) None of the above.
5. What is the difference between a class and an object?
o (A) A class is a blueprint for creating objects, while an object is an instance of a class.
o (B) A class is a logical entity, while an object is a physical entity.
o (C) A class can be inherited, while an object cannot.
o (D) All of the above.
6. What is the benefits of using inheritance?
o (A) Code reuse o (B) Polymorphism o (C) Maintainability o (D) All of the above
7. What is the difference between polymorphism and dynamic dispatch?
o (A) Polymorphism is the ability of an object to take on many forms, while dynamic dispatch is the process of determining which method to call based on the type of object at runtime.
o (B) Polymorphism is a compile-time feature, while dynamic dispatch is a runtime feature.
o (C) Polymorphism is achieved through inheritance, while dynamic dispatch is achieved through virtual functions.
o (D) All of the above.
Challenge Questions
8. Discuss the role of templates in C++.
9. How can RAII (Resource Acquisition Is Initialization) be used to prevent memory leaks in C++?
10.What are some of the best practices for designing and implementing object-oriented software?
11.Discuss the differences between C++ and other popular object- oriented programming languages, such as Java and Python.
12.What are some of the emerging trends in C++ and OOP?
I hope these questions are helpful!