- Type
- Quiz
- Course
- CS304P Object Oriented Programming (Practical)
- Size
- PDF 850 KB
- Updated
- 23 Oct 2026
You get 3 free files a day on the website. Add the Chrome extensionSign in with the extension for 30 a day.
Preview text
Text from pages 1, 2, 3 of 4. Download the file for all 4 pages.
Q1. In case of public inheritance between Base class A and Derived class B, which of the folllowing data members of Base class will be hidden in Derived class?
Correct answer: private
Q2. What is the purpose of explicit specialization in templates?
Correct answer: To handle specific data types that the template cannot handle successfully
Q3. For the given class definition, which one is correct? #include<iostream> using namespace std; class A{ int x,y; public: int Add(int a,int b){return a+b;} int Add(int c){return c;} };
Correct answer: Function Add is overloaded
Q4. The partial specialization pattern T* says that this specialization is to be used for every _______.
Correct answer: Pointer type
Q5. class A { public: int Test(int x) {return x*x;} int Test(int x,int y) {return x*y;} }; class B : public A { public: int Test(int x) { return x*x*x;} }; In the above class, the method Test is_______.
Correct answer: Both
Q6. Which of the following is the correct syntax to declare a vector of type int?
Correct answer: vector<int> sampleVector;
Q7. How can you define a class template in C++?
Correct answer: template<typename T> class MyClass { ... };
Q8. Suppose you have a function: void sum(); Choose correct syntax from the given options which will make this function pure virtual function.
Correct answer: virtual void sum()=0;
Q9. Which of the given is not a component of STL?
Correct answer: Cursor
Q10. Which of the following is the correct syntax for creating a function Test(T) friend of a template class?
Correct answer: friend void Test(T);
Q11. In a function template template<typename T>, what does T represent?
Correct answer: Type parameter
Q12. What feature enables same-named template functions to exist?
Correct answer: Function overloading
Q13. Which one of the following is an example of complete specialization?
Correct answer: template <typename T> class Vector { }
Q14. What does the compiler check first during template resolution?
Correct answer: Complete specialization
Q15. Which of the following is the correct syntax for a function template in C++?
Correct answer: template<class T> void func(T a);
Q16. If a function template has parameters `T` and `U`, calling `func(1, 2.5)` results in:
Correct answer: T=int, U=double
Q17. Which of the following is an example of partial specialization?
Correct answer: template<class T, float>
Q18. If Vector<char* > is instantiated, which version will the compiler choose?
Correct answer: Partial specialization
Related CS304P files
All CS304P files →Get more out of VUBuddy, for free
- Unlimited downloads
- The explanation behind every MCQ answer
- Study offline on slow data
- 30 downloads a day instead of 3
- Sign in and buy Pro Semester here
One Pro Semester membership works in both the extension and the app.