Explore topic-wise InterviewSolutions in .

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

51.

In Delphi ______________(a) Method overriding is done implicitly(b) Method overriding is not supported(c) Method overriding is done with directive override(d) Method overriding is done with the directive virtuallyThis question was posed to me at a job interview.My doubt is from Overriding Member Functions in chapter Member Functions & its Types of Object Oriented Programming

Answer»

Correct answer is (c) Method overriding is done with directive override

Best explanation: This is POSSIBLE but only if the method to be overridden is marked as dynamic or virtual. It is inbuilt restriction of programming LANGUAGE. This is done to REDUCE the accidental or unintentional overriding.

52.

In C# ____________________(a) Non – virtual or static methods can’t be overridden(b) Non – virtual and static methods only can be overridden(c) Overriding is not allowed(d) Overriding must be implemented using C++ code onlyThe question was posed to me in an interview for internship.This intriguing question comes from Overriding Member Functions topic in section Member Functions & its Types of Object Oriented Programming

Answer»

Right CHOICE is (a) NON – virtual or STATIC methods can’t be OVERRIDDEN

Easiest explanation - The non-virtual and static methods can’t be overridden in C# language. The restriction is made from the language implicitly. Only the methods that are abstract, virtual or OVERRIDE can be overridden.

53.

Which language doesn’t support the method overriding implicitly?(a) C++(b) C#(c) Java(d) SmallTalkThe question was asked during an interview.I would like to ask this question from Overriding Member Functions topic in section Member Functions & its Types of Object Oriented Programming

Answer»

Correct answer is (b) C#

To explain I would SAY: The feature of METHOD overriding is not provided in C#. To override the methods, ONE must use override or virtual keywords explicitly. This is done to REMOVE accidental changes in program and unintentional overriding.

54.

The functions to be overridden _____________(a) Must be private in base class(b) Must not be private base class(c) Must be private in both derived and base class(d) Must not be private in both derived and base classThe question was asked in an online interview.I'd like to ask this question from Overriding Member Functions in division Member Functions & its Types of Object Oriented Programming

Answer»

The CORRECT ANSWER is (b) Must not be PRIVATE base class

For explanation: If the FUNCTION is private in the base class, derived class won’t be able to access it. When the derived class can’t access the function to be overridden then it won’t be able to override it with any definition.

55.

How to access the overridden method of base class from the derived class?(a) Using arrow operator(b) Using dot operator(c) Using scope resolution operator(d) Can’t be accessed once overriddenThe question was posed to me at a job interview.The question is from Overriding Member Functions in section Member Functions & its Types of Object Oriented Programming

Answer»

Correct choice is (c) USING scope resolution operator

To EXPLAIN: Scope resolution operator :: can be USED to access the BASE class method even if overridden. To access those, first base class NAME should be written followed by the scope resolution operator and then the method name.

56.

Exactly same declaration in base and derived class includes______________(a) Only same name(b) Only same return type and name(c) Only same return type and argument list(d) All the same return type, name and parameter listI had been asked this question in an international level competition.Origin of the question is Overriding Member Functions in section Member Functions & its Types of Object Oriented Programming

Answer»

The correct answer is (d) All the same return type, NAME and parameter list

Explanation: Declaration includes the WHOLE prototype of the FUNCTION. The return type name and the parameter list must be same in order to CONFIRM that the function is same in derived and the base class. And hence can be overridden.

57.

Which is the correct condition for function overriding?(a) The declaration must not be same in base and derived class(b) The declaration must be exactly the same in base and derived class(c) The declaration should have at least 1 same argument in declaration of base and derived class(d) The declaration should have at least 1 different argument in declaration of base and derived classI had been asked this question in final exam.My question is based upon Overriding Member Functions topic in section Member Functions & its Types of Object Oriented Programming

Answer»

Correct option is (b) The declaration MUST be exactly the same in base and derived class

Best explanation: For a FUNCTION to be over ridden, the declaration must be exactly the same. There must not be any DIFFERENT syntax used. This will ensure that the function to be OVERRIDDEN is only the ONE intended from to be overridden from the derived class.

58.

Which among the following is true?(a) Inheritance must not be using when overriding is used(b) Overriding can be implemented without using inheritance(c) Inheritance must be done, to use overriding are overridden(d) Inheritance is mandatory only if more than one functionsThe question was asked in exam.This question is from Overriding Member Functions in portion Member Functions & its Types of Object Oriented Programming

Answer»

Right option is (C) Inheritance must be DONE, to use overriding are overridden

Best explanation: The inheritance must be used in order to use function overriding. If inheritance is not used, the functions can only be OVERLOADED. There must be a base class and a derived class to override the function of base class.

59.

Which among the following best describes member function overriding?(a) Member functions having same name in base and derived classes(b) Member functions having same name in base class only(c) Member functions having same name in derived class only(d) Member functions having same name and different signature inside main functionI have been asked this question in semester exam.My question comes from Overriding Member Functions in chapter Member Functions & its Types of Object Oriented Programming

Answer» CORRECT choice is (a) Member functions having same name in base and derived classes

The best I can explain: The member function which is defined in base class and again in the derived class, is overridden by the definition GIVEN in the derived class. This is because the preference is given more to the local members. When derived class OBJECT calls that function, definition from the derived class is used.
60.

Which operator can be used to free the memory allocated for an object in C++?(a) Free()(b) delete(c) Unallocate(d) CollectThe question was asked by my college director while I was bunking the class.My question is taken from Overloading Member Functions topic in section Member Functions & its Types of Object Oriented Programming

Answer»

The correct choice is (b) delete

Easy EXPLANATION - The delete operator in C++ can be used to FREE the memory and resources held by an object. The function can be called explicitly WHENEVER required. In C++ memory management must be DONE by the programmer. There is no AUTOMATIC memory management in C++.

61.

In java ______________ takes care of managing memory for objects dynamically.(a) Free collector(b) Dust collector(c) Memory manager(d) Garbage collectorThe question was posed to me by my school principal while I was bunking the class.This intriguing question originated from Overloading Member Functions topic in division Member Functions & its Types of Object Oriented Programming

Answer»

Correct answer is (d) Garbage collector

To EXPLAIN I would SAY: The garbage collector in JAVA takes care of the memory allocations and their deletions dynamically. When an OBJECT is no more required then the garbage collector deletes the object and free up all the RESOURCES that were held by that object.

62.

If an object is declared in a user defined function __________________(a) Its memory is allocated in stack(b) Its memory is allocated in heap(c) Its memory is allocated in HDD(d) Its memory is allocated in cacheI got this question during an online exam.I want to ask this question from Overloading Member Functions topic in section Member Functions & its Types of Object Oriented Programming

Answer» CORRECT choice is (a) Its memory is allocated in stack

The explanation is: The memory for any data or object that are used in a user defined function are always allocated in the stack. This is to ensure that the object is destroyed as SOON as the function is returned. Also this ensures that the correct memory ALLOCATION and destruction is PERFORMED.
63.

The memory allocated for an object ____________________(a) Can be only dynamic(b) Can be only static(c) Can be static or dynamic(d) Can’t be done using dynamic functionsThe question was posed to me in an internship interview.The query is from Overloading Member Functions topic in section Member Functions & its Types of Object Oriented Programming

Answer»

The CORRECT choice is (c) Can be static or dynamic

The explanation is: The memory allocation for an OBJECT can be static or dynamic. The static memory allocation is when an object is declared DIRECTLY without USING any function usually. And dynamic allocation is when we use some dynamic allocation function to ALLOCATE memory for data member of an object.

64.

Which operator can be used to check the size of an object?(a) sizeof(objectName)(b) size(objectName)(c) sizeofobject(objectName)(d) sizedobject(objectName)The question was asked in an interview.Question is from Overloading Member Functions in division Member Functions & its Types of Object Oriented Programming

Answer»

Correct choice is (a) sizeof(objectName)

To explain: The sizeof OPERATOR is used to get the size of an ALREADY created object. This operator MUST constail keyword sizeof(objectName). The output will give the number of bytes acquired by a single object of some class.

65.

Which function is called whenever an object goes out of scope?(a) Destructor function(b) Constructor function(c) Delete function(d) Free functionThe question was posed to me in an interview for job.My question is from Overloading Member Functions topic in section Member Functions & its Types of Object Oriented Programming

Answer»

The CORRECT choice is (a) Destructor function

To EXPLAIN: The destructor function of the class is called whenever an object GOES out of SCOPE. This is because the destructor set all the resources, acquired by the object, free. This is an implicit WORK of compiler.

66.

Which among the following keyword can be used to free the allocated memory for an object?(a) delete(b) free(c) either delete or free(d) only deleteI have been asked this question during an interview.This key question is from Overloading Member Functions topic in portion Member Functions & its Types of Object Oriented Programming

Answer» CORRECT answer is (c) either delete or free

The EXPLANATION is: The memory allocated for an object is usually automatically made free. But if EXPLICITLY memory has to be made free then we can use either free or delete keywords depending on PROGRAMMING languages.
67.

When is the memory allocated for an object gets free?(a) At termination of program(b) When object goes out of scope(c) When main function ends(d) When system restartsI got this question by my school principal while I was bunking the class.The above asked question is from Overloading Member Functions in division Member Functions & its Types of Object Oriented Programming

Answer»

Right option is (b) When OBJECT goes out of scope

Best explanation: Whenever an object goes out of scope, the deletion of allocation memory takes place. ACTUALLY the DATA is not deleted, instead the memory SPACE is flagged to be free for further use. Hence whenever an object goes out of scope the object members become useless and hence memory is set free.

68.

Which keyword among the following can be used to declare an array of objects in java?(a) new(b) create(c) allocate(d) arrThis question was posed to me during a job interview.My enquiry is from Overloading Member Functions in section Member Functions & its Types of Object Oriented Programming

Answer»

The correct answer is (a) new

Explanation: The keyword new can be used to declare an array of objects in java. The syntax must be specified with an object pointer which is assigned with a MEMORY space containing the required NUMBER of object space. EVEN initialization can be done DIRECTLY.

69.

Which of the following function can be used for dynamic memory allocation of objects?(a) malloc()(b) calloc()(c) create()(d) both malloc() and calloc()This question was posed to me during an interview.Origin of the question is Overloading Member Functions topic in portion Member Functions & its Types of Object Oriented Programming

Answer»

Right OPTION is (d) both malloc() and calloc()

The EXPLANATION: The malloc() function can be used to allocate DYNAMIC memory for objects. Function calloc() can also be USE. These functions differ in the way they allocate memory for objects.

70.

Using new is type safe as _______________________(a) It require to be specified with type of data(b) It doesn’t require to be specified with type of data(c) It requires the name of data(d) It allocated memory for the dataThe question was posed to me during an interview.My doubt is from Overloading Member Functions in chapter Member Functions & its Types of Object Oriented Programming

Answer»

Correct answer is (b) It doesn’t require to be specified with type of data

To explain: The NEW is type safe because we don’t have to specify the type of data that have to be allocated with memory. We can directly USE it with data name. Name of the data doesn’t matter though for type of memory ALLOCATION though.

71.

When is the memory allocated for an object?(a) At declaration of object(b) At compile time(c) When object constructor is called(d) When object is initialized to another objectThe question was posed to me in an online interview.The origin of the question is Overloading Member Functions topic in portion Member Functions & its Types of Object Oriented Programming

Answer» CORRECT CHOICE is (c) When OBJECT constructor is called

To explain: The object memory allocation takes place when the object constructor is called. Declaration of an object doesn’t mean that memory is allocated for its members. If object is initialized with ANOTHER object, it may just get a reference to the previously created object.
72.

Where is the memory allocated for the objects?(a) HDD(b) Cache(c) RAM(d) ROMI had been asked this question in examination.This interesting question is from Overloading Member Functions in division Member Functions & its Types of Object Oriented Programming

Answer»

Correct answer is (C) RAM

The best I can explain: The MEMORY for the objects or any other data is allocated in RAM initially. This is while we run a program all the memory allocation takes place in some RAM SEGMENTS. ARRAYS in heap and local members in stack etc.

73.

What does memory allocation for objects mean?(a) Actual creation and memory allocation for object members(b) Creation of member functions(c) Creation of data members for a class(d) Actual creation and data declaration for object membersThe question was asked in homework.This question is from Overloading Member Functions topic in division Member Functions & its Types of Object Oriented Programming

Answer»

The CORRECT OPTION is (a) Actual creation and memory allocation for object MEMBERS

The BEST explanation: The memory allocated for the object members indicates actual creation of the object members. This is known as memory allocation for object.

74.

Which operator among the following must be overloaded using the friend function?(a) > operator only(c) Both > operators(d) It’s not mandatory to use friend function in any caseI have been asked this question by my college professor while I was bunking the class.I want to ask this question from Member Operator Function in division Member Functions & its Types of Object Oriented Programming

Answer»

Right option is (C) Both << and >> operators

The best I can explain: In some cases it is mandatory to use the friend functions for overloading the operators. Here both the << and >> operators must be OVERLOADED using friend function because the LEFT operand is object of some other class and the right operand is usually of some DIFFERENT type.

75.

All the operators can be overloaded using the member function operator overloading.(a) True(b) FalseThis question was addressed to me in quiz.Enquiry is from Member Operator Function topic in portion Member Functions & its Types of Object Oriented Programming

Answer»

Right answer is (B) False

Explanation: It is not the case that all the operators can be overloaded using the MEMBER operator overloading. There are some CASES where the operators must be overloaded using the FRIEND function only. The REASON behind is that the left operand should be passed *this pointer, but the left operand in these cases might be object of some other class. Hence can’t be done.

76.

Which operator among the following can be overloaded using both friend function and member function?(a) Assignment operator(b) Subscript(c) Member selection (arrow operator)(d) Modulus operatorI have been asked this question in unit test.Origin of the question is Member Operator Function topic in chapter Member Functions & its Types of Object Oriented Programming

Answer»

Correct option is (d) Modulus OPERATOR

For explanation: Only the modulus operator among the given OPERATORS can be overloaded using either friend FUNCTION or member function. Other operators must be overloaded using only the member FUNCTIONS.

77.

Which operator among the following can be overloading using only member function?(a) Assignment operator(b) Addition operator(c) Subtraction operator(d) Multiplication and division operatorI got this question in unit test.This intriguing question comes from Member Operator Function topic in division Member Functions & its Types of Object Oriented Programming

Answer»

The correct answer is (a) Assignment operator

Explanation: Only the assignment operator AMONG the options given must be overloaded using the member functions. The assignment operator can’t be overloaded using friend FUNCTION. This is a restriction in the programming languages to make the PROGRAMS more resistant TOWARDS errors.

78.

Where in the parameter list is the implicit *this is added?(a) Right most parameter(b) Anywhere in parameter list(c) Left most parameter(d) Not added to parameter listI had been asked this question during an internship interview.I would like to ask this question from Member Operator Function topic in chapter Member Functions & its Types of Object Oriented Programming

Answer»

Correct choice is (c) Left most parameter

To explain I would say: The left operand is PASSED implicitly by the compiler to the member function. But this is DONE, when the compiler adds the CALLING OBJECT as *this to the parameter list. It is ALWAYS added as the left most parameter, i.e. the first parameter of the function.

79.

When the friend operator overloading is converted into member operator overloading _______________(a) Two parameters of friend function remains same parameters in member operator overloading(b) Two parameters of friend function becomes only one parameter of member function(c) Two parameters of friend function are removed while using member function(d) Two parameters of friend function are made 4 in member operator overloadingThe question was posed to me during a job interview.The origin of the question is Member Operator Function in portion Member Functions & its Types of Object Oriented Programming

Answer»

The correct choice is (b) Two parameters of friend function BECOMES only one PARAMETER of member function

To explain I would say: The friend function would accept two ARGUMENTS if some binary operator is overloaded. When we try to CONVERT that definition to member operator overloading then it becomes only one parameter. The reason behind is that the left operand is passed implicitly while using the member functions.

80.

If left operand member is specified directly in the function definition, which is the correct implicit conversion of that syntax?(a) *this className(b) *this parameterObject(c) *this returnedObject(d) *this objectI got this question at a job interview.This is a very interesting question from Member Operator Function in division Member Functions & its Types of Object Oriented Programming

Answer» RIGHT choice is (d) *this object

The explanation is: SINCE the left operands are passed implicitly, those object members can be accessed directly in the function definition. The compiler converts the syntax into the syntax that can be processed. The implicitly converted syntax contains *this POINTER FOLLOWED by the objectName that is left operand in the expression.
81.

Which object’s members can be called directly while overloading operator function is used (In function definition)?(a) Left operand members(b) Right operand members(c) All operand members(d) None of the membersI had been asked this question in an international level competition.Question is taken from Member Operator Function in chapter Member Functions & its Types of Object Oriented Programming

Answer»

Right answer is (a) LEFT operand members

To EXPLAIN I would say: This is because the left operand is passed implicitly. It is pointed by *this. This in turn means we can use the direct member NAMES of the OBJECT because those are again converted to a syntax CONTAINING *this pointer implicitly.

82.

Why the left parameter is removed from parameter list?(a) Because it is of no use(b) Because it is never used in definitions(c) Because it becomes parameter pointed by *this(d) Because it can’t be referred by *this pointerI have been asked this question in exam.Question is from Member Operator Function in chapter Member Functions & its Types of Object Oriented Programming

Answer» RIGHT choice is (c) Because it becomes parameter pointed by *this

The best I can explain: The LEFT OBJECT is REMOVED from being passed as a parameter, because it is implicitly passed. It is passed implicitly because it is considered the object with respect to which the OVERLOADING function is being called.
83.

What is the syntax to overload an operator?(a) className::operator(parameters)(b) className:operator(parameters)(c) className.operator(paramteres)(d) className->operator(parameters)I had been asked this question in an online interview.I'd like to ask this question from Member Operator Function in division Member Functions & its Types of Object Oriented Programming

Answer»

Correct answer is (a) CLASSNAME::operator(parameters)

To explain I would say: The CLASS name is followed by the scope resolution operator. This is DONE to specify the class to which the FUNCTION should belong to. Then the KEYWORD operator should be used in order to indicate the operator that is to be overloaded. Then come the parameters list to specify other operands.

84.

If a friend overloaded operator have to be changed to member overloaded operator, which operator should be used with the class name?(a) Scope resolution operator(b) Colon(c) Arrow operator(d) Dot operatorI had been asked this question during an interview.This is a very interesting question from Member Operator Function topic in chapter Member Functions & its Types of Object Oriented Programming

Answer»

Correct choice is (a) Scope resolution OPERATOR

Best explanation: The scope resolution operator can be used followed by the class name. Then the operator keyword with the operator symbol that should be OVERLOADED. This is done to USE member function INSTEAD of FRIEND function.

85.

If the left operand is pointed by *this pointer, what happens to other operands?(a) Other operands are passed as function return type(b) Other operands are passed to compiler implicitly(c) Other operands must be passed using another member function(d) Other operands are passed as function argumentsThis question was addressed to me by my college professor while I was bunking the class.Question is taken from Member Operator Function in chapter Member Functions & its Types of Object Oriented Programming

Answer»

The CORRECT choice is (d) Other operands are PASSED as FUNCTION arguments

The explanation is: The operands that are USED during overloading expect the left operand, can be passed as function arguments. Those are then referred in function definition with the names specified in the argument list.

86.

When the operator to be overloaded becomes the left operand member then ______________(a) The right operand acts as implicit object represented by *this(b) The left operand acts as implicit object represented by *this(c) Either right or left operand acts as implicit object represented by *this(d) *this pointer is not applicable in that member functionI have been asked this question in unit test.I'm obligated to ask this question of Member Operator Function in section Member Functions & its Types of Object Oriented Programming

Answer»

Correct CHOICE is (B) The left operand acts as IMPLICIT object represented by *this

The best I can EXPLAIN: The left operand becomes the object that is referred by *this pointer in the member function that will be called while using operator overloading. This is done to point to a specific object on which the overloading will be applied.

87.

Which among the following is mandatory condition for operators overloading?(a) Overloaded operator must be member function of the left operand(b) Overloaded operator must be member function of the right operand(c) Overloaded operator must be member function of either left or right operand(d) Overloaded operator must not be dependent on the operandsThe question was asked in an interview for job.The question is from Member Operator Function topic in section Member Functions & its Types of Object Oriented Programming

Answer»

The correct option is (a) Overloaded operator MUST be member FUNCTION of the left operand

To explain I would say: The operator to be overloaded must be made the member function of the operand on left side of EXPRESSIONS to be used. This allows the compiler to identify whether the overloading has to be used or not. This rule also reduces the ambiguity in CODE.

88.

Which among the following are valid ways of overloading the operators?(a) Only using friend function(b) Only using member function(c) Either member functions or friend functions can be used(d) Operators can’t be overloadedThe question was posed to me during an interview for a job.This interesting question is from Member Operator Function in division Member Functions & its Types of Object Oriented Programming

Answer»

Correct choice is (c) EITHER member functions or friend functions can be USED

Easy explanation - The OPERATORS can be OVERLOADED by using the member function or even the friend functions can be used. This is because both of these can access all the data members of a class.

89.

Which keyword is used to define the inline member function?(a) no keyword required(b) inline(c) inlined(d) lineThis question was posed to me in a national level competition.This intriguing question comes from Types of Member Functions in division Member Functions & its Types of Object Oriented Programming

Answer»

Right choice is (b) inline

To explain: The inline keyword is used to defined the inline MEMBER functions in a class. The functions are IMPLICITLY MADE inline if defined inside the class body, but only if they doesn’t have any complex STATEMENT inside. All functions defined outside the class body must be mentioned with an explicit inline keyword.

90.

Which keyword is used to define the static member functions?(a) static(b) stop(c) open(d) stateThis question was addressed to me in homework.I'm obligated to ask this question of Types of Member Functions in portion Member Functions & its Types of Object Oriented Programming

Answer» RIGHT choice is (a) static

Best explanation: The static keyword is used to DECLARE any static member function in a CLASS. The static members become common to each object of the class being created. They share the same VALUES.
91.

Which among the following is true?(a) Member functions can never be private(b) Member functions can never be protected(c) Member functions can never be public(d) Member functions can be defined in any access specifierThe question was posed to me in an international level competition.This is a very interesting question from Types of Member Functions in section Member Functions & its Types of Object Oriented Programming

Answer»

Correct ANSWER is (d) Member functions can be defined in any ACCESS SPECIFIER

The best EXPLANATION: The member functions can be defined inside any specifier. There is no restriction. The programmer can APPLY restrictions on its use by specifying the access specifier with the functions.

92.

All type of member functions can’t be used inside a single class.(a) True(b) FalseThis question was posed to me in examination.I'd like to ask this question from Types of Member Functions topic in division Member Functions & its Types of Object Oriented Programming

Answer»

Correct choice is (b) False

The explanation: There is no restriction on the use of type of MEMBER FUNCTIONS inside a single CLASS. Any type any number of times can be defined inside a class. The member functions can be USED as required.

93.

Member functions _____________________(a) Must be defined inside class body(b) Can be defined inside class body or outside(c) Must be defined outside the class body(d) Can be defined in another classThis question was addressed to me in a job interview.This key question is from Types of Member Functions in chapter Member Functions & its Types of Object Oriented Programming

Answer»

Right choice is (C) Must be defined outside the class body

The best explanation: The functions DEFINITIONS can be given inside or outside the body of class. If defined inside, general SYNTAX is used. If defined outside then the class name followed by scope RESOLUTION operator and then function name must be given for the DEFINITION.

94.

Which keyword is used to make a nonmember function as friend function of a class?(a) friendly(b) new(c) friend(d) connectThis question was addressed to me in an online quiz.Origin of the question is Types of Member Functions topic in chapter Member Functions & its Types of Object Oriented Programming

Answer»

Correct ANSWER is (c) friend

The best explanation: The keyword friend is provided in PROGRAMMING LANGUAGES to USE it WHENEVER a functions is to be made friend of one class or other. The keyword indicates that the function is capable of new functionalities like accessing private members.

95.

What is the syntax of a const member function?(a) void fun() const {}(b) void fun() constant {}(c) void const fun() {}(d) const void fun(){}I had been asked this question during an online exam.My doubt is from Types of Member Functions topic in portion Member Functions & its Types of Object Oriented Programming

Answer»

The correct OPTION is (a) void fun() CONST {}

EASY explanation - The general syntax to be followed in ORDER to declare a const function in a class is as in option a. The syntax may vary in different programming languages.

96.

What are friend member functions (C++)?(a) Member function which can access all the members of a class(b) Member function which can modify any data of a class(c) Member function which doesn’t have access to private members(d) Non-member functions which have access to all the members (including private) of a classI had been asked this question in a job interview.Origin of the question is Types of Member Functions in section Member Functions & its Types of Object Oriented Programming

Answer»

The correct choice is (d) Non-MEMBER FUNCTIONS which have access to all the members (including private) of a class

The best explanation: A non-member function of a class which can access even the private data of a class is a FRIEND function. It is an EXCEPTION on access to private members outside the class. It is sometimes CONSIDERED as a member functions since it has all the access that a member function in general have.

97.

Which among the following best describes the inline member functions?(a) Functions defined inside the class only(b) Functions with keyword inline only(c) Functions defined outside the class(d) Functions defined inside the class or with the keyword inlineThe question was asked during an internship interview.The query is from Types of Member Functions topic in chapter Member Functions & its Types of Object Oriented Programming

Answer»

Correct option is (d) Functions defined inside the CLASS or with the KEYWORD inline

Easiest explanation - The functions which are defined with the keyword inline or are defined inside the class are treated to be inline functions. Definitions inside the class are implicitly made inline if none of the COMPLEX statements are used in the definition.

98.

What are const member functions?(a) Functions in which none of the data members can be changed in a program(b) Functions in which only static members can be changed(c) Functions which treat all the data members as constant and doesn’t allow changes(d) Functions which can change only the static membersI got this question in a job interview.This interesting question is from Types of Member Functions topic in chapter Member Functions & its Types of Object Oriented Programming

Answer»

Right option is (C) FUNCTIONS which treat all the data members as constant and doesn’t ALLOW changes

The best I can explain: The CONST member functions are intended to keep the value of all the data members of a class same and doesn’t allow any changes on them. The data members are treated as constant data and any modification inside the const FUNCTION is restricted.

99.

Correct syntax to access the static member functions from the main() function is ______________(a) classObject::functionName();(b) className::functionName();(c) className:classObject:functionName();(d) className.classObject:functionName();The question was asked in a national level competition.I want to ask this question from Types of Member Functions topic in chapter Member Functions & its Types of Object Oriented Programming

Answer»

Right choice is (B) CLASSNAME::functionName();

Easy explanation - The syntax in option b must be followed in order to CALL the static functions directly from the MAIN() FUNCTION. That is a predefined syntax. Scope resolution helps to spot the correct function in the correct class.

100.

How can static member function can be accessed directly in main() function?(a) Dot operator(b) Colon(c) Scope resolution operator(d) Arrow operatorI got this question by my college director while I was bunking the class.This interesting question is from Types of Member Functions topic in chapter Member Functions & its Types of Object Oriented Programming

Answer»

The correct option is (C) Scope resolution operator

The explanation is: The static MEMBER functions can be accessed directly in the main() function. The only restriction is that those must use only static data MEMBERS of the CLASS. These functions are property of class RATHER than each object.