cpp94

Upload: dejuan-huff

Post on 03-Jun-2018

216 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/12/2019 cpp94

    1/4

    1. What is C++?

    C++ language was developed by Bjarne Stroustrup in AT&T Bell Labs which are an extension of C language. It

    an object oriented programming language which is used for developing commercial and enterprise application

    Visual C++ of Microsoft became the best and perfect choice for the programmers and developers.

    2. Mention the fundamental concepts of object oriented programming language?

    It is mandatory to understand vital concepts which are highly used in the object oriented programming languag

    Includes:

    Objects Classes

    Inheritance

    Encapsulation and data abstraction

    Polymorphism Message passing

    Dynamic binding

    3. Define encapsulation?

    Encapsulation is wrapping up of functions and data in a single unit. This single is nothing but a class. Informatiabout an object is hidden such as code and the internal data structure in encapsulation.

    4. What is an inheritance?

    Inheritance is deriving a new class from the old class and the old class is known as base class whereas new class

    known as derived class. The main usage of inheritance is reuse of the existing code than rewriting the code fro

    scratch when it is required. In this process, object o one class obtains properties of other class.

    5. Define polymorphism?

    Polymorphism is one name with different forms. In the program, it permits you to have more than one function wisame name. It helps in overloading so an operation is shown in different behaviors differently.

    6. Define message passing?

    A set of objects is present in an object oriented programs for communicating with each other. Specifying the nam

    of object, information to be sent and the function name is included in message passing.

    7. Define tokens in C++?

    In a program, the smallest individual units are known as tokens. The following are the tokens of C++ programmin

    language: Identifiers

    Strings

    Constants Keywords

    Operators

  • 8/12/2019 cpp94

    2/4

    8. What is a constructor?

    The member function which has a same name of its class is known as a constructor. When an object of a class

    created then invoking of a constructor takes place. The name constructor is given because it constructs values data members of class.

    9. Where do you use enumerated data type?

    Enumerated data type is a user defined data type which is used to attach names to numbers to increa

    unambiguousness of code. Lists of words are enumerated automatically by enum keyword by assigning then valu0, 1, 2, 3, etc.

    10. Why the default constructor is used?

    A default constructor is a constructor which does not accept any parameters is known as a default constructor.

    11. Define destructor?

    For an object class, a destructor is called when the object is out of the scope or it is deleted explicitly. As the nam

    implies, the destructor is used to destroy objects that are created by the constructors. The destructor is also a memb

    function like the constructor whose name is its class name but it is preceded by tilde.

    12. Does variable declaration in C++ differ from C?

    Yes. In the C language, variables are declared in the beginning of scope whereas in C++, anywhere in the scovariables can be declared. Understanding is made easy to the programmer as variables are declared in the context

    usage.

    13. Define a class?

    A class is a template which contains data members and member functions.

    14. Differentiate C and C++?

    The main difference between C and C++ is C is a procedure oriented language whereas C++ is an objected orientprogramming language. C language is considered as a super set of C++. Function overloading, inheritance a

    method overloading are not supported by C language whereas C++ supports them. In a C program, main functi

    need not return a value whereas it must return a value in C++.

    15. Define a copy constructor?

    The constructor which has the same name of a class and which is used to copy the objects deeply is known as a co

    constructor.

  • 8/12/2019 cpp94

    3/4

    16. Define a scope resolution operator?

    An identifier is referenced in the global scope which is hidden by other identifier with same name in local scopeallowed by the scope resolution operator.

    17. Distinguish object and instance?

    Object is an instance of user-defined type. From one class, multiple objects can be instantiated whereas an instan

    of a class is object.

    18. Differentiate macro and inline?

    A strict parameter type checking is followed by inline but it is not followed by macro. Preprocessor is used to expand macros and the inline definitions may or may not be replaced by the compiler.

    19. Define Multiple Inheritance?

    The class which inherits or acquires properties from many classes then it is known as inheritance.

    20. Define implicit conversion?

    Automatic conversion is performed by C++ if the data type are mixed in the expression. Smaller type is changed

    wider type. Integer converting to float type is an example.

    21. In C++, give the usage of virtual destructor?

    If the object is destroyed then the destructor is called automatically. In C++, virtual destructor is mainly used avoid resource leaks by doing clean-up of an object.

    22. In C++, what is a reference variable?

    An alias is provided by a reference variable to a variable which is previously defined.

    23. Describe virtual functions?

    The virtual functions must belong to particular class.

    They are not static members.

    Object pointers are used to gain access these virtual functions. A virtual function may be a friend of other class.

    24. Mention inheritance advantages?

  • 8/12/2019 cpp94

    4/4

    Time is saved in developing a program. Code can be reused.

    25. Define dynamic constructor?

    While creating objects, memory is allocated using constructors. Objects are allocated memory at the constructi

    time which is known as dynamic construction of objects. Here, allocation of memory can be done using an operat

    called new.

    26. Why declaration is used?

    Name is used from a namespace if it is declared.

    27. Define conversion constructor?

    The constructor which has a single parameter that is declared without using function specifier is known as

    conversion constructor. The converting constructors are used to convert from first parameter type to converti

    constructors class type.

    28. Define associative container?

    Associative containers are specially designed to provide gain access to elements with keys. In general, t

    associative containers are of four types, they are: Map

    Set

    Multimap

    Multiset

    29. Give some pure object oriented languages?

    Java

    Smalltalk Sather

    Eiffel

    The candidate who is looking for the interview questions on C++ is at the right place as this article has the exa

    information to prepare for the interview. These interview questions are given appropriate and easy answers so ththe candidate can remember them easily. Generally, most of the people find difficulty in clearing the technical rou

    of an interview so they can face the interview easily after going through these