C++ Templates Quiz

C++ Templates Quiz

University

10 Qs

quiz-placeholder

Similar activities

java2/67

java2/67

12th Grade - University

10 Qs

3F_14042025_Verifica per orale Informatica

3F_14042025_Verifica per orale Informatica

11th Grade - University

10 Qs

Mastering C++ Functions

Mastering C++ Functions

University

15 Qs

Quiz Meet 2 Mini SC Programing

Quiz Meet 2 Mini SC Programing

University

10 Qs

Parcial 1 Reparación y Soporte- 5to BACO - I Unidad Forma B

Parcial 1 Reparación y Soporte- 5to BACO - I Unidad Forma B

10th Grade - University

13 Qs

Revisão linguagem C - questões abertas

Revisão linguagem C - questões abertas

University

5 Qs

Quiz Pemrograman Arduino

Quiz Pemrograman Arduino

10th Grade - University

15 Qs

NESTED-IF, FOR & WHILE LOOP By handawnz

NESTED-IF, FOR & WHILE LOOP By handawnz

University

12 Qs

C++ Templates Quiz

C++ Templates Quiz

Assessment

Quiz

Information Technology (IT)

University

Hard

Created by

Yasmin Kandil

Used 10+ times

FREE Resource

10 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is a template in C++?

A predefined function

A blueprint for creating functions or classes

A type of variable

A keyword in C++

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which of the following is a correct way to define a function template?

 `template function<int> void func() {}`

`template <typename T> void func() {}`

`function template<T> void func() {}`


`template <T> void func() {}`

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the primary benefit of using templates in C++?

Improved performance

Code reuse and type safety

Simplicity of syntax

Increased memory usage

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which of the following statements about class templates is true?

Class templates cannot have member functions.

Class templates are not type safe.

Class templates can be instantiated with different types.

Class templates require a return type.

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

How do you instantiate a template class with the type `int`?

`MyClass<int> obj;`

`MyClass obj<int>;`

`MyClass obj(int);`

`MyClass<int> obj();`

6.

MULTIPLE SELECT QUESTION

45 sec • 1 pt

What keyword is used to define a template parameter that can accept any type?

`var`

`template`

`typename`

`class`

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which of the following is an example of a template specialization?

`MyClass<int> obj();`

`template<> void func<int>() {}`

`template<type T> void func() {}`

`void func() {}`

Create a free account and access millions of resources

Create resources
Host any resource
Get auto-graded reports
or continue with
Microsoft
Apple
Others
By signing up, you agree to our Terms of Service & Privacy Policy
Already have an account?