Take FREE!! Online Mettl Mock Test to Crack TechM and Other Companies Written Exams.
Get Off-Campus Placement Jobs Info !!!
Practice Tech Mahindra Essay Topics

Technical Interview Questions and Answers :: C++

    111 / 184

    What are the benefits of templates?
    Answer:

    • Templates allow implementing the concept of generic programming.
    • Template allows us to generate a family of classes or a family of functions to handle different data types.
    • Template classes and functions eliminate code duplication for different types and thus make the program development easier and more manageable.
    • We can use multiple parameters in both the class templates and function templates.
    • Like other functions, templates can be overloaded.

    Please Login First :

    112 / 184

    What is meant by exception?
    Answer:

    Some peculiar problems other than logic or syntax errors, they are known as exceptions. Exceptions are run-time anomalies or unusual conditions that a program may encounter while executing. Anomalies might include the condition such a division by zero, array outside of bound etc.

    Please Login First :

    113 / 184

    What is meant by exception handling mechanism?
    Answer:

    Exception handling mechanism is basically built upon through keywords namely try, catch, and throw. The keyword try is used to preface a block of statements which may generate an exception. This block of statements is known as try block. When an exception is detected, it is thrown using a throw statement in the try block. A catch statement is defined by the keyword catch “catches” the exception thrown by the throw statement in the try block.

    Please Login First :

    114 / 184

    What are the purpose of the exception handling?
    Answer:

    The purpose of exception handling mechanism is to provide means to detect and report an “exception circumstance”. So that appropriate action can be taken. The mechanism suggests a separate error handling code that performs the following tasks.
    1. Find the problem (hit the exception).
    2. Inform than an error has occurred (throw the exception).
    3. Receives the error information (catch the exception).
    4. Take corrective action (handle the exception).

    Please Login First :

    115 / 184

    Explain throwing mechanism briefly?
    Answer:

    When an exception that is desired to be handled is detected, it is thrown using throw statement in one of the following forms:
    Throw(exception)
    Throw exception;
    Throw; // used for re-throwing an exception.

    Please Login First :

    116 / 184

    Explain multiple catch statements?
    Answer:

    It is possible that a program segment has more than one condition to throw an exception. In such case we can associate more than one catch statement with a try. For eg:

    Try
    {
    //try block;
    }
    catch (type 1 arg)
    {
    // catch block1;
    }
    catch (type 2 arg)
    {
    // catch block 2;
    }
    ……………….
    ……………….
    Catch (type n arg)
    {
    // catch block n;
    }

    Please Login First :

    117 / 184

    Explain briefly about rethrowing an exception?
    Answer:

    A handler may decide to rethrow the exception caught without processing it. In such situation, we may simply invoke throw without any argument.
    Eg: throw;
    This cause the current exception to be thrown to the next enclosing try/catch sequence and is caught by a catch statement listed after that enclosing try block.

    Please Login First :

    118 / 184

    What is STL? What are its three components?
    Answer:

    A collection of generic classes and function is called the standard template library (STL). STL components are part of c++ standard library. STL consist of three main components. They are
    • Containers
    • Algorithms
    • Iterators

    Please Login First :

    119 / 184

    What is meant by container?
    Answer:

    A container is an object that actually stores data. It is a way data is organized in memory, the STL containers are implemented by template classes and therefore can be easily customized to hold different types of data.

    Please Login First :

    120 / 184

    What are the types of Iterators that are supported by each container class?
    Answer:

    There are three major categories of containers:
    • Sequence container
    1) Vectors
    2) Dequeue
    3) list

    • Associative container
    1. set
    2. multiset
    3. map
    4. multimap
    • Derived container
    1. stack
    2. queue
    3. priority queue

    Please Login First :



You can check latest and updated Important C++ Interview Questions and Answers on this page. You can filter the question set by the company's name. Looking for the right answer? Don't worry! You can click on view answer section and check the answer with the explanation. You can discuss the answer in the forum with other users easily. Login with Facebook and save the answer To Reading List right now!

Our site contains top IT companies placement paper and mock test to help the freshers and experienced candidate to get hands on experience on the pattern and type of questions. We have curated all the C++ technical interview questions and answers from previous candidates.