Covid-19 Update!!    We have enabled all courses through virtual classroom facility using Skype or Zoom.    Don't stop learning.    Enjoy Learning from Home.

30% Discount Python        30% Discount Webdesign        30% Discount SEO        30% Discount Angular8        Free SQL Class        Free Agile Workshop       Free HTML Sessions        Free Python Basics

Important CC++ Interview Questions and Answers

C / C++ Interview Questions

1. Explain what is a class in C++?

A class in C++ can be defined as a collection of function and related data under a single name. It is a blueprint of objects. A C++ program can consist of any number of classes.

2. Explain what is the use of void main () in C++ language?

To run the C++ application it involves two steps, the first step is a compilation where conversion of C++ code to object code take place. While second step includes linking, where combining of object code from the programmer and from libraries takes place. This function is operated by main () in C++ language.

3. Explain what are the characteristics of Class Members in C++?

  • Data and Functions are members in C++,
  • Within the class definition, data members and methods must be declared
  • Within a class, a member cannot be re-declare
  • Other that in the class definition, no member can be added elsewhere

    4. Explain what is Member Functions in Classes?

    The member function regulates the behaviour of the class. It provides a definition for supporting various operations on data held in the form of an object.

    5. Explain what is Loop function? What are different types of Loops?

    In any programming language, to execute a set of statements repeatedly until a particular condition is satisfied Loop function is used. The loop statement is kept under the curly braces { } referred as Loop body.
    In C++ language, three types of loops are used
  • While loop
  • For loop
  • Do-while loop

    6. Explain how functions are classified in C++ ?

    In C++ functions are classified as
  • Return type
  • Function Name
  • Parameters
  • Function body

    7. Explain what are Access specifiers in C++ class? What are the types?

    Everything has control in a web page which is introduced as an elements, there are different ways are Access specifiers determine the access rights for the statements or functions that follow it until the end of class or another specifier is included. Access specifiers decide how the members of the class can be accessed.
    There are three types of specifiers
  • Private
  • Public
  • Protected

    8. Explain what is a reference variable in C++?

    A reference variable is just like a pointer with few differences. It is declared using & Operator. In other words, reference is another name for an already existing variable.

    9. Explain what is Polymorphism in C++?

    Polymorphism in C++ is the ability to call different functions by using only one type of the function call. Polymorphism is referred to codes, operations or objects that behave differently in a different context.
    For example, the addition function can be used in many contests like
     Integer additionץ 5+5 
     The same ( + ) operator can be used with different meaning with stringsץ Medical+Internship 
     The same ( + ) operator can be used for floating point additi◊
    • 3.14 + 2.27  The same ( + ) operator can be used for floating point addition◊
    

    10. Explain what is C++ exceptional handling?

    The problem that arises during execution of a program is referred as exceptional handling.
    The exceptional handling in C++ is done by three keywords.
    Try: It identifies a block of code for which particular exceptions will be activated
    Catch: The catch keyword indicates the catching of an exception by an exception handler at the place in a program
    Throw: When a problem exists while running the code, the program throws an exception
  • 11. Explain what is data encapsulation in C++?

    Encapsulation is an object oriented programming concept (oops) which binds together the data and functions. It is also referred as data hiding mechanism.

    12. Mention what are the types of Member Functions?

    The types of member functions are
  • Simple functions
  • Static functions
  • Const functions
  • Inline functions
  • Friend functions

    13. Explain what is multi-threading in C++?

    To run two or more programs simultaneously multi-threading is useful.
    There are two types of
    Process-based: It handles the concurrent execution of the program
    Thread-based: It deals with the concurrent execution of pieces of the same program

    14. Explain what is upcasting in C++?

    Converting the derived class pointer to the base class pointer or converting the derived class reference to the base class reference is called as upcasting.

    15.Write an example for virtual function

    For example, in the following virtual function program bp is a pointer of type Base, but a call to bp->show() calls show() function of Derived class, because bp points to an object of Derived class.
    #include< iostream > 
    using namespace std; 
      
    class Base { 
    public: 
        virtual void show() { cout<<" In Base \n"; } 
    }; 
      
    class Derived: public Base { 
    public: 
        void show() { cout<<"TIB Academy \n"; }  
    }; 
      
    int main(void) {    
        Base *bp = new Derived;      
        bp->show();  // RUN-TIME POLYMORPHISM 
        return 0; 
    }