Skip to content
VUBuddy

CS304P Quiz 4 by Shahid and Ziddi

Object Oriented Programming (Practical) PDF 845 KBUpdated 23 Oct 2026
Quiz CS304P Quiz 4 by Shahid and Ziddi PDF 845 KB
vubuddy.com
Type
Quiz
Course
CS304P Object Oriented Programming (Practical)
Size
PDF 845 KB
Updated
23 Oct 2026
Free download 0 of 3 used today
Download free · 845 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 of 2. Download the file for all 2 pages.

Q1. Which of the following is true about friend functions in template classes?

  1. They can only access public members of the class.
  2. They must be defined inside the class.
  3. They are inherited by derived classes.
  4. They can access private and protected members of the class.

Correct answer: They can access private and protected members of the class.

Q2. What keyword is used to define a generic function template?

  1. typename
  2. generic
  3. template
  4. class

Correct answer: template

Q3. If a function template has parameters `T` and `U`, calling `func(1, 2.5)` results in:

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

Correct answer: T=int, U=double

Q4. When is a class template instantiated?

  1. When linked
  2. When declared
  3. At runtime
  4. At compile time

Correct answer: At compile time

Q5. Which of the following is the correct syntax for creating a template class X friend of a template class Y?

  1. X<T> friend;
  2. X<T>;
  3. friend X;
  4. friend X<T>;

Correct answer: friend X<T>;

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

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

Correct answer: Specialization

Q7. Which keyword is used to define a template in C++?

  1. class
  2. function
  3. typename
  4. template

Correct answer: template

Q8. To accept two type parameters, __________ is written.

  1. template<class T, U>
  2. template<typename T U>
  3. template<class T U>
  4. template<typename T, typename U>

Correct answer: template<typename T, typename U>

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

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

Correct answer: friend void Test(T);

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

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

Correct answer: template<class T, float>

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.