Skip to content
VUBuddy

CS304P Quiz 4 Set 2

Object Oriented Programming (Practical) PDF 850 KBUpdated 23 Oct 2026
Quiz CS304P Quiz 4 Set 2 PDF 850 KB
vubuddy.com
Type
Quiz
Course
CS304P Object Oriented Programming (Practical)
Size
PDF 850 KB
Updated
23 Oct 2026
Free download 0 of 3 used today
Download free · 850 KB

You get 3 free files a day on the website. Add the Chrome extension for 30 a day.

Unlimited downloads in the Android app Get it free on Google Play

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?

  1. public
  2. protected
  3. private
  4. both public and private

Correct answer: private

Q2. What is the purpose of explicit specialization in templates?

  1. To handle specific data types that the template cannot handle successfully
  2. To simplify the template syntax
  3. To avoid the use of templates
  4. To improve runtime performance

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;} };

  1. None of the given options
  2. Function Add is overloaded
  3. Function Add is overridden
  4. Function Add has an error

Correct answer: Function Add is overloaded

Q4. The partial specialization pattern T* says that this specialization is to be used for every _______.

  1. Meta type
  2. Data type
  3. Virtual type
  4. Pointer type

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_______.

  1. Both
  2. Overloaded
  3. Overridden
  4. None of the given options

Correct answer: Both

Q6. Which of the following is the correct syntax to declare a vector of type int?

  1. vector {int} sampleVector;
  2. sampleVector vector<int> ;
  3. vector<int> sampleVector;
  4. int <vector> sampleVector;

Correct answer: vector<int> sampleVector;

Q7. How can you define a class template in C++?

  1. template<name T> class MyClass { ... };
  2. template<class T> MyClass { ... };
  3. template<type T> class MyClass { ... };
  4. template<typename T> class MyClass { ... };

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.

  1. void sum()=0;
  2. virtual void sum()=0;
  3. void sum() virtual=0;
  4. sum()=0;

Correct answer: virtual void sum()=0;

Q9. Which of the given is not a component of STL?

  1. Container
  2. Iterator
  3. Cursor
  4. Algorithm

Correct answer: Cursor

Q10. Which of the following is the correct syntax for creating a function Test(T) friend of a template class?

  1. void Test(T);
  2. friend void Test(T);
  3. void friend Test(T);
  4. void Test(T) friend;

Correct answer: friend void Test(T);

Q11. In a function template template<typename T>, what does T represent?

  1. Non-type parameter
  2. Built-in type
  3. Function return value
  4. Type parameter

Correct answer: Type parameter

Q12. What feature enables same-named template functions to exist?

  1. Inheritance
  2. Function overloading
  3. Polymorphism
  4. Specialization

Correct answer: Function overloading

Q13. Which one of the following is an example of complete specialization?

  1. template <typename T> class Vector<T*> { }
  2. template <typename T> class Vector { }
  3. template <class T> class Vector<T *> { }
  4. template<> class Vector <char*> { }

Correct answer: template <typename T> class Vector { }

Q14. What does the compiler check first during template resolution?

  1. Partial specialization
  2. General template
  3. Function overloading
  4. Complete specialization

Correct answer: Complete specialization

Q15. Which of the following is the correct syntax for a function template in C++?

  1. template void func<class T>(T a);
  2. template<class T> void func(T a);
  3. template<type T> func(T a);
  4. func<class T>(T a);

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:

  1. Both deduced as double
  2. Both deduced as int
  3. Compilation error
  4. T=int, U=double

Correct answer: T=int, U=double

Q17. Which of the following is an example of partial specialization?

  1. template<class T, float>
  2. template<int>
  3. template<class T, class U>
  4. template<int , float , char>

Correct answer: template<class T, float>

Q18. If Vector<char* > is instantiated, which version will the compiler choose?

  1. Function overloading
  2. General template
  3. Partial specialization
  4. Complete specialization

Correct answer: Partial specialization

All CS304P files →
CS304P Object Oriented Programming (Practical) All CS304P handouts, past papers, quizzes and MCQs in one place. Open course page

Get more out of VUBuddy, for free

Android app Free on Google Play
  • Unlimited downloads
  • The explanation behind every MCQ answer
  • Study offline on slow data
Get the Android app
Chrome extension Free on the Chrome Web Store
  • 30 downloads a day instead of 3
  • Sign in and buy Pro Semester here
Add to Chrome

One Pro Semester membership works in both the extension and the app.