Explore topic-wise InterviewSolutions in Current Affairs.

This section includes 7 InterviewSolutions, each offering curated multiple-choice questions to sharpen your Current Affairs knowledge and support exam preparation. Choose a topic below to get started.

1.

Are There Any New Intrinsic (built-in) Data Types?

Answer»

Yes. The ANSI committee ADDED the bool intrinsic type and its TRUE and false value KEYWORDS.

Yes. The ANSI committee added the bool intrinsic type and its true and false value keywords.

2.

What Problem Does The Namespace Feature Solve?

Answer»

Multiple providers of libraries might use common GLOBAL identifiers CAUSING a name collision when an application tries to link with two or more such libraries. The NAMESPACE feature surrounds a library’s external declarations with a unique namespace that eliminates the potential for those collisions. This solution assumes that two library vendors don’t use the same namespace IDENTIFIER, of COURSE.

Multiple providers of libraries might use common global identifiers causing a name collision when an application tries to link with two or more such libraries. The namespace feature surrounds a library’s external declarations with a unique namespace that eliminates the potential for those collisions. This solution assumes that two library vendors don’t use the same namespace identifier, of course.

3.

Describe Run-time Type Identification.?

Answer»

The ABILITY to DETERMINE at RUN time the TYPE of an object by using the typeid operator or the dynamic_cast operator.

The ability to determine at run time the type of an object by using the typeid operator or the dynamic_cast operator.

4.

What Is The Standard Template Library?

Answer»

A LIBRARY of container templates approved by the ANSI committee for INCLUSION in the standard C++ SPECIFICATION.

A programmer who then launches into a discussion of the generic programming model, iterators, allocators, algorithms, and such, has a higher than average understanding of the new technology that STL brings to C++ programming.

A library of container templates approved by the ANSI committee for inclusion in the standard C++ specification.

A programmer who then launches into a discussion of the generic programming model, iterators, allocators, algorithms, and such, has a higher than average understanding of the new technology that STL brings to C++ programming.

5.

What Is An Explicit Constructor?

Answer»

A conversion constructor DECLARED with the explicit KEYWORD. The COMPILER does not use an explicit constructor to implement an implied conversion of TYPES. It’s purpose is reserved explicitly for construction.

A conversion constructor declared with the explicit keyword. The compiler does not use an explicit constructor to implement an implied conversion of types. It’s purpose is reserved explicitly for construction.

6.

What Is A Mutable Member?

Answer»

One that can be modified by the class EVEN when the object of the class or the member function doing the MODIFICATION is CONST.

One that can be modified by the class even when the object of the class or the member function doing the modification is const.

7.

When Is A Template A Better Solution Than A Base Class?

Answer»

When you are designing a generic class to CONTAIN or OTHERWISE manage objects of other types, when the format and BEHAVIOR of those other types are unimportant to their containment or management, and particularly when those other types are unknown (thus, the genericity) to the DESIGNER of the container or MANAGER class.

When you are designing a generic class to contain or otherwise manage objects of other types, when the format and behavior of those other types are unimportant to their containment or management, and particularly when those other types are unknown (thus, the genericity) to the designer of the container or manager class.

8.

Explain The Isa And Hasa Class Relationships. How Would You Implement Each In A Class Design?

Answer»

A specialized class "is" a specialization of another class and, therefore, has the ISA RELATIONSHIP with the other class. An EMPLOYEE ISA Person. This relationship is BEST implemented with inheritance. Employee is derived from Person. A class may have an instance of another class. For EXAMPLE, an employee "has" a salary, therefore the Employee class has the HASA relationship with the Salary class. This relationship is best implemented by embedding an OBJECT of the Salary class in the Employee class.

A specialized class "is" a specialization of another class and, therefore, has the ISA relationship with the other class. An Employee ISA Person. This relationship is best implemented with inheritance. Employee is derived from Person. A class may have an instance of another class. For example, an employee "has" a salary, therefore the Employee class has the HASA relationship with the Salary class. This relationship is best implemented by embedding an object of the Salary class in the Employee class.

9.

What Is A Virtual Destructor?

Answer»

The simple ANSWER is that a virtual destructor is ONE that is DECLARED with the virtual attribute.

The simple answer is that a virtual destructor is one that is declared with the virtual attribute.

10.

When Should You Use Multiple Inheritance?

Answer»

There are three ACCEPTABLE answers: "Never," "RARELY," and "When the problem DOMAIN cannot be accurately MODELED any other WAY."

There are three acceptable answers: "Never," "Rarely," and "When the problem domain cannot be accurately modeled any other way."

11.

What Is The Difference Between A Copy Constructor And An Overloaded Assignment Operator?

Answer»

A copy constructor constructs a new OBJECT by using the CONTENT of the ARGUMENT object. An overloaded assignment operator ASSIGNS the contents of an existing object to ANOTHER existing object of the same class.

A copy constructor constructs a new object by using the content of the argument object. An overloaded assignment operator assigns the contents of an existing object to another existing object of the same class.

12.

What Is A Conversion Constructor?

Answer»

A constructor that ACCEPTS ONE ARGUMENT of a DIFFERENT TYPE.

A constructor that accepts one argument of a different type.

13.

What Is Your Reaction To This Line Of Code?

Answer»

It’s not a GOOD PRACTICE.

It’s not a good practice.

14.

How Does Throwing And Catching Exceptions Differ From Using Setjmp And Longjmp?

Answer»

The THROW OPERATION calls the destructors for automatic objects instantiated SINCE entry to the TRY block.

The throw operation calls the destructors for automatic objects instantiated since entry to the try block.

15.

How Many Ways Are There To Initialize An Int With A Constant?

Answer»

Two. There are two formats for initializers in C++ as shown in the example that follows.

The first format uses the traditional C NOTATION.

The second format uses CONSTRUCTOR notation.

int foo = 123;

int BAR (123);

Two. There are two formats for initializers in C++ as shown in the example that follows.

The first format uses the traditional C notation.

The second format uses constructor notation.

int foo = 123;

int bar (123);

16.

What Are The Differences Between A C++ Struct And C++ Class?

Answer»

The DEFAULT MEMBER and base-class ACCESS SPECIFIERS are DIFFERENT.

The default member and base-class access specifiers are different.

17.

Explain The Scope Resolution Operator?

Answer»

It permits a PROGRAM to REFERENCE an IDENTIFIER in the GLOBAL scope that has been HIDDEN by another identifier with the same name in the local scope.

It permits a program to reference an identifier in the global scope that has been hidden by another identifier with the same name in the local scope.

18.

How Do You Link A C++ Program To C Functions?

Answer»

By using the extern "C" linkage SPECIFICATION AROUND the C FUNCTION DECLARATIONS.

By using the extern "C" linkage specification around the C function declarations.

19.

Where Virtual Inheritance Should Be Used In A Hierarchy?

Answer»

If we have a diamond CLASS HIERARCHY we should use the virtual INHERITANCE just below the TOP of the diamond.

If we have a diamond class hierarchy we should use the virtual inheritance just below the top of the diamond.

20.

Can I Call Destructor Explicitly?

Answer»

YES, but you only WANT to do that when you have USED PLACEMENT NEW.

Yes, but you only want to do that when you have used placement new.

21.

Can I Overload Destructor?

Answer»

No

No

22.

Can I Have Static Members In An Union?

Answer»

No

No

23.

What Is The Difference Between Exit And Abort?

Answer»

exit does a graceful process termination, it calls the DESTRUCTORS for all the constructed OBJECTS, with abort they are not called.

With exit the local With variables of the CALLING FUNCTION and its CALLERS will not have their destructors invoked.

exit does a graceful process termination, it calls the destructors for all the constructed objects, with abort they are not called.

With exit the local With variables of the calling function and its callers will not have their destructors invoked.

24.

How To Declare C Function In C++?

Answer»

By USING EXTERN "C".

extern "C" VOID PRINT();

or 

extern "C" { 

void print();

}

By using extern "C".

extern "C" void print();

or 

extern "C" { 

void print();

}

25.

How To Declare A Namespace Alias?

Answer»

 NAMESPACE MyLongNameSpaceName

{

...

}

namespace MLNSN = MyLongNameSpaceName;

 namespace MyLongNameSpaceName

{

...

}

namespace MLNSN = MyLongNameSpaceName;

26.

What Is The Size Of Class With Only Virtual Functions?

Answer»

4 with most of the COMPILERS for a 32BIT BINARY.

4 with most of the compilers for a 32bit binary.

27.

What Is The Size Of An Empty Class, Or Class With Only Normal Functions?

Answer»

Not ZERO, 1 for most compilers. The reason for this is to have DIFFERENT address for different object.

Not zero, 1 for most compilers. The reason for this is to have different address for different object.

28.

What Is A Possible Replacement For C Static Function In C++?

Answer»

UNNAMED NAMESPACES.

Unnamed namespaces.

29.

What Is The Difference Between Calling Just Throw And Throw With An Object In A Catch Block?

Answer»

A COPY of the OBJECT is CREATED if we THROW with an object. With just throw, no copy is created.

A copy of the object is created if we throw with an object. With just throw, no copy is created.

30.

Does Friends Are Inherited?

Answer»

No

No

31.

Can I Use This Pointer In The Constructor?

Answer»

Yes, but TRY to avoid CALLING VIRTUAL function from the constructor and passing this pointer from the initialization LIST to other classes.

Yes, but try to avoid calling virtual function from the constructor and passing this pointer from the initialization list to other classes.

32.

What Is A Default Constructor?

Answer»
  1.  A CONSTRUCTOR which TAKES no ARGUMENT
  2.  A constructor which has argument(s) but is(are) with DEFAULT VALUE

33.

What Is The Difference Between Std::vector<int> X; And Std::vector<int> X();?

Answer»

FIRST one declares a variable x of type STD::vector&LT;INT>. SECOND one declares a function x which returns std::vector<int>.

First one declares a variable x of type std::vector<int>. Second one declares a function x which returns std::vector<int>.

34.

What Is The Memory Structure Of An Object?

Answer»

Usually C++ objects are MADE by concatenating MEMBER VARIABLES.

For example;

class Test

{

int i;

float j;

};

is represented by an int followed by a float.

class TestSub: public Test

{

int K;

};

The above class is represented by Test and then an int(for int k). So FINALLY it will be int, float and int.

In addition to this each object will have the vptr(virtual pointer) if the class has virtual function, usually as the first element in a class.

Usually C++ objects are made by concatenating member variables.

For example;

class Test

{

int i;

float j;

};

is represented by an int followed by a float.

class TestSub: public Test

{

int k;

};

The above class is represented by Test and then an int(for int k). So finally it will be int, float and int.

In addition to this each object will have the vptr(virtual pointer) if the class has virtual function, usually as the first element in a class.

35.

Can The Destructor Be Pure Virtual Function?

Answer»

YES, but you STILL have to DEFINE it!

Yes, but you still have to define it!

36.

What Is The Issue In The Following Program?

Answer»

 #include <iostream&GT;

int MAIN(int argc, char **argv)

{

const int & r1 = 100;

int v = 200;

int &r2 = v;

int & r3 = 200;

return 0;

}

 Issue is in the initialization of r3 at line 8, rvalue should be a variable.

 #include <iostream>

int main(int argc, char **argv)

{

const int & r1 = 100;

int v = 200;

int &r2 = v;

int & r3 = 200;

return 0;

}

 Issue is in the initialization of r3 at line 8, rvalue should be a variable.

37.

What Is Constant In A Const Function?

Answer»

VARIABLE 'this'.

Variable 'this'.

38.

How To Initialize Constant And Reference Member Variable?

Answer»

USING INITIALIZATION LIST.

Using initialization list.

Previous Next