LakshyaEducation.in

VEDIC MATHS Video Series
  • Home
  • Video Series
    • Vedic Maths Videos
    • Quantitative Aptitude Videos
    • Class 8 Maths Videos
    • Class 9 Maths Videos
    • Class 10 Maths Videos
  • Quiz & Solutions
  • Blog
  • Store
  • Login
  • Contact Us
  • Home
  • Topic
  • C++ Programming
  • Specialization

C++ Programming

SPECIALIZATION MCQs

Total Questions : 10

Question 1.

What is other name of full specialization?


  1.    explicit specialization
  2.    implicit specialization
  3.    function overloading template
  4.    None of the mentioned
 Discuss Question
Answer is Option A. -> explicit specialization

None

Question 2.

How many types of specialization are there in c++?


  1.    1
  2.    2
  3.    3
  4.    4
 Discuss Question
Answer is Option B. -> 2

There are two types specialization. They are full specialization and partial specialization.

Question 3.


What is the output of this program?



1.
#include
2.
using namespace std;
3.
template class A
4.
{
5.
public:
6.
A();
7.
int value;
8.
};
9.
template class A
10.
{
11.
public: A();
12.
};
13.
template class A
14.
{
15.
public: A();
16.
};
17.
template A::A() : value(i)
18.
{
19.
cout
  1.    6
  2.    10
  3.    6default10
  4.    None of the mentioned
 Discuss Question
Answer is Option C. -> 6default10

In this program, We are defining three templates and specializing it and passing the values to 

it and printing it.
Output:
$ g++ spec5.cpp
$ a.out
6default10

Question 4.


What is the output of this program?



1.
#include
2.
#include
3.
#include
4.
using namespace std;
5.
template
6.
type MyMax(const type Var1, const type Var2)
7.
{
8.
cout
  1.    template
  2.    class
  3.    no specialization
  4.    None of the mentioned
 Discuss Question
Answer is Option A. -> template

In this program, We are computing the result in the specalized block of the program.
Output:
$ g++ spec3.cpp
$ a.out
template

Question 5.


What is the output of this program?



1.
#include
2.
using namespace std;
3.
template
4.
class XYZ
5.
{
6.
public:
7.
void putPri();
8.
static T ipub;
9.
private:
10.
static T ipri;
11.
};
12.
template
13.
void XYZ::putPri()
14.
{
15.
cout
  1.    template
  2.    class
  3.    no specialization
  4.    None of the mentioned
 Discuss Question
Answer is Option A. -> template

Answer:d
Explanation:
In this program, We are passing the value of specified type and printing it by specialization.
Output:
$ g++ spec2.cpp
$ a.out
1
1
1.2

Question 6.


What is the output of this program?



1.
#include
2.
using namespace std;
3.
template
4.
T multIt(T x)
5.
{
6.
for(int ii = 0; ii < count; ii++)
7.
{
8.
x = x * x;
9.
}
10.
return x;
11.
};
12.
int main()
13.
{
14.
float xx = 2.1;
15.
cout
  1.    2.1
  2.    378.228
  3.    2.1: 378.228
  4.    None of the mentioned
 Discuss Question
Answer is Option C. -> 2.1: 378.228

In this program, We specifed the type in the template function. We need to compile this program by adding -std=c++0x.
Output:
$ g++ -std=c++0x spec1.cpp
$ a.out
2.1: 378.228

Question 7.

Which is similar to template specialization?


  1.    template
  2.    function overloading
  3.    function template overloading
  4.    None of the mentioned
 Discuss Question
Answer is Option C. -> function template overloading

None

Question 8.

Which is called on allocating the memory for array of objects?


  1.    destructor
  2.    constructor
  3.    method
  4.    None of the mentioned
 Discuss Question
Answer is Option B. -> constructor

When you allocate memory for an array of objects, the default constructor must be called to 

construct each object. If no default constructor exists, you’re stuck needing a list of pointers 

to objects.

Question 9.

What is meant by template specialization?


  1.    It will have certain data types to be fixed.
  2.    It will make certain data types to be dynamic.
  3.    Certain data types are invalid
  4.    None of the mentioned
 Discuss Question
Answer is Option A. -> It will have certain data types to be fixed.

In the template specialization, it will make the template to be specific for some data types.

Question 10.


What is the output of this program?



1.
#include
2.
using namespace std;
3.
template
4.
inline T square(T x)
5.
{
6.
T result;
7.
result = x * x;
8.
return result;
9.
};
10.
template
11.
string square(string ss)
12.
{
13.
return (ss+ss);
14.
};
15.
int main()
16.
{
17.
int i = 2, ii;
18.
string ww("A");
19.
ii = square(i);
20.
cout
  1.    2:4AA
  2.    2:4
  3.    AA
  4.    2:4A
 Discuss Question
Answer is Option A. -> 2:4AA

Template specialization is used when a different and specific implementation is to be used for a 

specific data type. In this program, We are using integer and character.
Output:
$ g++ spec.cpp
$ a.out
2:4AA

  • Share on Facebook!
  • Share on Pinterest!

Sub Topics

  • Abstract Classes
  • Access Control
  • Argument Passing
  • Arrays
  • Booleans
  • C++ Concepts
  • Catching Exceptions
  • Character Types
  • Class Hierarchies And Abstract Classes
  • Class Hierarchies Introduction
  • Classes
  • Comments And Indentation
  • Complex Number Type
  • Constants
  • Constructors And Destructors
  • Container Design
  • Conversion Operators
  • Declaration
  • Default Arguments
  • Dereferencing
  • Derivation And Templates
  • Derived Classes
  • Design Of Class Hierarchies
  • Enumerations
  • Error Handling
  • Error Handling Alternatives
  • Essential Operators
  • Exception Specifications
  • Exceptions
  • Exceptions And Efficiency
  • Exceptions That Are Not Errors
  • Floating Point Types
  • Free Store
  • Friends
  • Function Call
  • Function Declarations
  • Function Templates
  • Functions
  • Grouping Of Exceptions
  • Header Files Usage
  • Increment And Decrement
  • Integer Types
  • Large Objects
  • Linkage
  • Macros
  • Modularization And Interfaces
  • Multiple Inheritance
  • Namespaces
  • Objects
  • Objects And Classes
  • Oops Concepts
  • Operator Functions
  • Operators
  • Overloaded Function Names
  • Pointer To Function
  • Pointer To Void
  • Pointers
  • Pointers Into Arrays
  • Pointers To Members
  • References
  • Resource Management
  • Run Time Type Information
  • Sequence Adapters
  • Sequences
  • Simple String Template
  • Sizes
  • Specialization
  • Standard Exceptions
  • Standard Library Design
  • Statements
  • String Class
  • Structures
  • Subscripting
  • Template Arguments To Specify Policy Usage
  • Types
  • Uncaught Exceptions
  • Unspecified Number Of Arguments
  • User Defined Types
  • Value Return
  • Vector
  • Void

Recent Posts

  • Vedic Maths Faq
  • Sail E0 Exam Results Cancelled - Exam Will Be Rescheduled
  • Quantitative Aptitude Faqs
  • Ssc Exam Guide Book
  • Best Ssc Exam For Girls
  • Is Ssc Difficult Than Upsc?
  • Sail E0 Results 2022

Recent Questions

Q.   A Static Function

Q.   Specify The Material Of Construction Suitable For Handling C....

Q.   Data Collection Terminals Gather Data For Use By The

Q.   Living Together Of A Man And Woman Without Being Married To ....

Q.   The Role Of Asp 102 And His 57 During Trypsin Catalysis Is T....

Q.   Which Of The Following Formulas Will Excel Not Be Able To Ca....

Q.   The Included Angle For The V-belt Is Usually

Q.   (solve As Per The Direction Given Above)

Q.   Two Cards Are Drawn Together At Random From A Pack Of 52 Car....

Q.   The Radius Of Fluorine Atom Is

Q.   Which Of The Following Statements Is Incorrect?

Q.   What Are the Different Categories Of Plants? Explain. [....

Q.   Fermentation Medium For Oxytetracyclin (terramycin) Consist ....

Q.   Suspended Solids Are Measured By Which Of The Following?

Q.   In A Cantilever Of Span Subjected To A Point Load Of W Actin....

Q.   Which Among The Following Is Related To The Word Mesoderm ?

Q.   In The Pour Plate Method, The Mixed Culture Is Diluted Direc....

Q.   COMFORT

Q.   The News Agency Reuters Belongs To Which Of The Following Co....

Q.   Very Small Amount Of Air Pollutants Are Present In Stratosph....

Topics

Computer Aptitude
SAIL Junior Officer (E-0)
10th Grade
11th Grade
12th Grade
4th Grade
5th Grade
6th Grade
7th Grade
8th Grade
9th Grade
NCERT
Cat
Commerce
Computer Science
Engineering
English
General Knowledge
Ias
Management
Quantitative Aptitude
Reasoning Aptitude
General Studies (Finance And Economics)
Vedic Maths
Analytical Instrumentation
Biochemistry
Bioinformatics
Biology
Biotechnology
Bitsat
Business Statistics
C Programming
C++ Programming
Cell Biology
Chemistry
Cost Accounting
Drug And Pharmaceutical Biotechnology
Electrical Measurement And Instrumentation
Environment Management
Environmental Biotechnology
Enzyme Technology
Financial Management And Financial Markets
Gate
General Science
Geography
Heat Transfer
History And National Movements
Human Anatomy And Physiology
Human And Cultural Diversity
Human Resource Management
Indian Economy
Indian Geography
Indian History
Indian Polity
Instrumentation Transducers
International Relations
Life Sciences
Marketing And Marketing Management
Mass Transfer
Mechanics Of Materials
Microbiology
Neet
Professional Communication
Renewable Energy
Sociology
Surveying
Total Quality Management
Uidai Aadhaar Supervisor Certification
Virology
LakshyaEducation.in
Lakshya Education
Bhilai,Chattisgarh,India
Email: admin@lakshyaeducation.in Phone: 07893519977 (WhatsApp)

Quick Links

  • Vedic Maths
  • Quantitative Aptitude
  • Class – IX Maths
  • Class – X Maths
  • Blog

Our Services

  • About us
  • Privacy
  • TOS
  • Refund / Cancellation
  • Contact
  • Affiliate Program
  • Copyright © 2022 All Right Reserved | Lakshya Education     ( )
    Login / Register

    Your Account will be created automatically when you click the below Google or Facebook Login Button.
    •   Login With Facebook
    •  Login With Google
     Login With Email/Password