Technical Interview Questions and Answers :: iGate
- Select All
- Java
- C++
- Oracle PLSQL
- WebMethod
- Informatica
- Operating System
- Networking
- SQL
- HR Question in TR
- DBMS
- Soft. Engineering
- C
- Data Structure
- Hadoop
- .NET
11 / 160
A virtual function allows derived classes to replace the implementation provided by the base class. The compiler makes sure the replacement is always called whenever the object in question is actually of the derived class, even if the object is accessed by a base pointer rather than a derived pointer. This allows algorithms in the base class to be replaced in the derived class, even if users don't know about the derived class.
12 / 160
As the name suggests, the function acts as a friend to a class. As a friend of a class, it can access its private and protected members. A friend function is not a member of the class. But it must be listed in the class definition.
13 / 160
Structure: Initially (in C) a structure was used to bundle different type of data types together to perform a particular functionality. But C++ extended the structure to contain functions also. The major difference is that all declarations inside a structure are by default public.
Class: Class is a successor of Structure. By default all the members inside the class are private.
14 / 160
Ø Public, protected and private are three access specifier in C++.
Ø Public data members and member functions are accessible outside the class.
Ø Protected data members and member functions are only available to derived classes.
Ø Private Data members and member functions can’t be accessed outside the class. However there is an exception can be using friend classes.
15 / 160
The :: operator links a class name with a member name in order to tell the complier what class the member belongs to. It has another use that is it can allow access to a name in an enclosing scope that is hidden by a local declaration of the same name.
Egname.
Eg:
Void f()
{
int I;
I=10;
………..
……..
}
It may do so by preceding the I with the :: as shown here
Void f()
{
int I;
:: I=10;
……..
……..
}
16 / 160
In C , function declaration is means telling the compiler that a function occurs but there's no definition given to it. When in the program, the function with definition is given, it's known as function definition.
For eg.: void display();//function declaration
void display){ cout<<"Function Definition";}//Function Definition
17 / 160
This means if one member variable of union is updated then the rest will be updated as well. This also leads compilation error when initializing multiple members at a time as the memory locations are not different. So in case of union only one member should be initialized at a time.
18 / 160
Preprocessor directives are lines included in the code of programs preceded by a hash sign (#
). These lines are not program statements but directives for the preprocessor. The preprocessor examines the code before actual compilation of code begins and resolves all these directives before any code is actually generated by regular statements.
19 / 160
By using a friend function.
A friend function has access to all private and protected members of the class for which it is a friend.
20 / 160
1. C can run most of the code of C, but C can't run C code.
2. C supports procedural programming paradigm whereas C supports both procedural and object oriented programming paradigm.
3. C is a function driven and C is an object driven language.
4. C doesn't allow function definitions within structures whereas in C function definition can be within structures.
5. C doesn't support reference variables but C does support.