Technical Interview Questions - C++ & OOPS

C++ QUESTIONS

  • · What is a class?
  • · What is an object?
  • · What is the difference between an object and a class?
  • · What is the difference between class and structure?
  • · What is public, protected, private?
  • · What are virtual functions?
  • · What is friend function?
  • · What is a scope resolution operator?
  • · What do you mean by inheritance?
  • · What is abstraction?
  • · What is polymorphism? Explain with an example.
  • · What is encapsulation?
  • · What do you mean by binding of data and functions?
  • · What is function overloading and operator overloading?
  • · What is virtual class and friend class?
  • · What do you mean by inline function?
  • · What do you mean by public, private, protected and friendly?
  • · When is an object created and what is its lifetime?
  • · What do you mean by multiple inheritance and multilevel inheritance? Differentiate between them.
  • · Difference between realloc() and free?
  • · What is a template?
  • · What are the main differences between procedure oriented languages and object oriented languages?
  • · What is R T T I ?
  • · What are generic functions and generic classes?
  • · What is namespace?
  • · What is the difference between pass by reference and pass by value?
  • · Why do we use virtual functions?
  • · What do you mean by pure virtual functions?
  • · What are virtual classes?
  • · Does c++ support multilevel and multiple inheritance?
  • · What are the advantages of inheritance?
  • · When is a memory allocated to a class?
  • · What is the difference between declaration and definition?
  • · What is virtual constructors/destructors?
  • · In c++ there is only virtual destructors, no constructors. Why?
  • · What is late bound function call and early bound function call? Differentiate.
  • · How is exception handling carried out in c++?
  • · When will a constructor executed?
  • · What is Dynamic Polymorphism?
  • · Write a macro for swapping integers.

Replies

  • Sahithi Pallavi
    Sahithi Pallavi
    Encapsulation is the mechanism that binds together the code and the data it manipulates and keeps both safe from outside interference and misuse.

    Inheritance is the process of inheriting all the features from a class. The advantages of inheritance are reusability of code and accessibility of variables and methods of the super class by subclasses. So that the programmer can develop the subclasses so easily and Hence the Productivity of the Programmer and the Organisation will Increase.

    In POP, programming logic follows certain procedures and the instructions are executed one after another whereas in OOP program, unit of program is object, which is nothing but combination of data and code. And In procedural program, data is exposed to the whole program whereas in OOPs program, it is accessible with in the object and which in turn assures the security of the code.


    I will be happy if anyone correct me and anyone explain in detail with some examples if you can.
  • Ankita Katdare
    Ankita Katdare
    Dynamic Polymorphism:

    When an entity changes its form depending on the circumstances it is called as Dynamic Polymorphism.
    Polymorphism, as the word suggests, when we have more than one form.

    A function is said to exhibit dynamic polymorphism when calls to its various forms are resolved dynamically when the program is executed i.e. via 'late binding' i.e. at run-time instead of compile time.
  • Ankita Katdare
    Ankita Katdare
    RTTI : It stands for Run Time Type Information/Identification.

    It means the information about an object's data type is made available at run-time.
    This is a C++ implementation of a more generic concept called reflection or, more specifically, type introspection.

    The dynamic_cast<> operation and typeid operator in C++ are part of RTTI.
  • Sahithi Pallavi
    Sahithi Pallavi
    AbraKaDabra
    Dynamic Polymorphism:

    When an entity changes its form depending on the circumstances it is called as Dynamic Polymorphism.
    Polymorphism, as the word suggests, when we have more than one form.

    A function is said to exhibit dynamic polymorphism when calls to its various forms are resolved dynamically when the program is executed i.e. via 'late binding' i.e. at run-time instead of compile time.
    @Akd : Can you give me an example?
  • Ankita Katdare
    Ankita Katdare
    @sahithi: Yes.

    In C++, one way to get late binding is to use function pointers (a type of pointer that points to a function instead of a variable)
    The function that a function pointer points to can be called by using the function call operator (()) on the pointer.

    For e.g:

    int Add(int x, int y)
    {
        return x + y;
    }
    int main()
    {
    // Create a function pointer and make it point to the Add function
        int (*p)(int, int) = Add;
    cout << p(5, 3) << endl;
        return 0;
    }

You are reading an archived discussion.

Related Posts

DATA STRUCTURE QUESTIONS · What is a data structure? · What does abstract data type means? · Evaluate the following prefix expression " ++ 26 + - 1324" (Similar types...
JAVA QUESTIONS · What is the difference between an Abstract class and Interface? · What is user defined exception? · What do you know about the garbage collector? · What...
Advanced JAVA questions · What is RMI? · Explain about RMI Architecture? · What are Servelets? · What is the use of servlets? · Explain RMI Architecture? · How will...
Operating System Questions · What are the basic functions of an operating system? · Explain briefly about, processor, assembler, compiler, loader, linker and the functions executed by them. · What...
MICROPROCESSOR QUESTIONS · Which type of architecture 8085 has? · How many memory locations can be addressed by a microprocessor with 14 address lines? · 8085 is how many bit...