Technical Interview Questions and Answers :: iGate
Tot. Mock Test: 11
Total Qs: 160+
No Discussion on this question yet!
Friend classes are used when two or more classes are designed to work together and need access to each others implementation in ways that the rest of the world shouldnâ€™t be allowed to have. In other words, they help keep private things private. For instance, it may be desirable for class Database Cursor to have more privilege to the internals of class Database than main () has.
Function overloading: C++ enables several functions of the same name to be defined, as long as these functions have different sets of parameters (at least as far as their types are concerned). This capability is called function overloading. When an overloaded function is called, the C++ compiler elects the proper function by examining the number, types and order of the arguments in the call. Function overloading is commonly used to create several functions of the same name that perform similar tasks but on different data types.
Operator overloading allows existing C++ operators to be redefined so that they work on objects of user-defined classes. Overloaded operators are syntactic sugar for equivalent function calls. They form a pleasant facade that doesn't add anything fundamental to the language (but they can improve understand ability and reduce maintenance costs).
The free subroutine frees a block of memory previously allocated by the malloc subroutine. Undefined results occur if the Pointer parameter is not a valid pointer. If the Pointer parameter is a null value, no action will occur. The realloc subroutine changes the size of the block of memory pointed to by the Pointer parameter to the number of bytes specified by the Size parameter and returns a new pointer to the block. The pointer specified by the Pointer parameter must have been created with the malloc, calloc, or realloc subroutines and not been deallocated with the free or realloc subroutines. Undefined results occur if the Pointer parameter is not a valid pointer
Abstraction is of the process of hiding unwanted details from the user.
Encapsulation is binding of attributes and behaviors. Hiding the actual implementation and exposing the functionality of any object. Encapsulation is the first step towards OOPS, is the procedure of covering up of data and functions into a single unit (called class). Its main aim is to protect the data from out side world.
Classes and objects are separate but related concepts. Every object belongs to a class and every class contains one or more related objects.
Ã˜ A Class is static. All of the attributes of a class are fixed before, during, and after the execution of a program. The attributes of a class don't change.
Ã˜ The class to which an object belongs is also (usually) static. If a particular object belongs to a certain class at the time that it is created then it almost certainly will still belong to that class right up until the time that it is destroyed.
Ã˜ An Object on the other hand has a limited lifespan. Objects are created and eventually destroyed. Also during that lifetime, the attributes of the object may undergo significant change.
Single entity showing multiple behaviours.
Example: Mobile can be used to take photos , internet usage,text documents creation etc.,
Two types of polymorphism 1.static polymorphism ( method over riding)
2. Dynamic polymorphism ( method over loading)
No Discussion on this question yet!
A scope resolution operator (::), can be used to define the member functions of a class outside the class.