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.

1.

All the public member functions ___________________(a) Can’t access the private members of a class(b) Can’t access the protected members of a class(c) Can access only public members of a class(d) Can access all the member of its classThis question was posed to me in an international level competition.My enquiry is from Public Member Functions in section Member Functions & its Types of Object Oriented Programming

Answer»

Right choice is (d) Can access all the member of its class

The EXPLANATION is: The PUBLIC member function can access any PRIVATE, protected and public member of its class. Not only public member function, any member function of a class can access each and EVERY other member DECLARED inside the class. Hence are flexible to program.

2.

The function main() must always be public.(a) True(b) FalseI have been asked this question in semester exam.Enquiry is from Public Member Functions topic in chapter Member Functions & its Types of Object Oriented Programming

Answer»

Right choice is (a) True

To explain: The main() function MUST always be public. This is because the whole function and the OPERATING system that is out of the PACKAGE have to access the main function throughout the program EXECUTION. Hence the main() function should be public so as to be available everywhere in the program.

3.

If a class have a public member function and is called directly in the main function then ___________________________(a) Undeclared function error will be produced(b) Out of memory error is given(c) Program gives warning only(d) Program shut down the computerThe question was asked in quiz.Enquiry is from Public Member Functions in section Member Functions & its Types of Object Oriented Programming

Answer» RIGHT choice is (a) Undeclared function error will be produced

The best EXPLANATION: If the function is called directly WITHOUT using any object then the compiler doesn’t gets to know that the function have to be called from a SPECIFIC CLASS. And if there are no global or in-scope function with same name then the compiler produces an error stating that the called function is undeclared.
4.

A derived class object can access the public members of the base class.(a) True(b) FalseI got this question in final exam.I'd like to ask this question from Public Member Functions topic in division Member Functions & its Types of Object Oriented Programming

Answer»

Correct choice is (b) False

To explain I would say: The public MEMBERS of the base class can be accessed from the DERIVED class object only if public inheritance is used. If PROTECTED or PRIVATE inheritance is used then those members become public/protected in derived class and hence won’t be able to be CALLED from object of the derived class.

5.

If public members are to be restricted from getting inherited from the subclass of the class containing that function, which alternative is best?(a) Make the function private(b) Use private inheritance(c) Use public inheritance(d) Use protected inheritanceI have been asked this question by my college director while I was bunking the class.I'd like to ask this question from Public Member Functions topic in division Member Functions & its Types of Object Oriented Programming

Answer»

Correct ANSWER is (B) Use private inheritance

The EXPLANATION is: If private inheritance is USED then the class CONTAINING the function will be able to use the function with rules of whichever specifier is used. Then the derived class makes those function the private members of itself. This restricts the public members of parent class from further inheritance.

6.

Which public function call among the following is correct outside the class, if return type is void (C++)?(a) object.void functionName(parameters);(b) object.functionName(parameters);(c) object.functionName void (parameters)(d) object.void functionName();This question was posed to me in an interview for internship.Question is from Public Member Functions topic in chapter Member Functions & its Types of Object Oriented Programming

Answer»

The correct OPTION is (b) object.functionName(parameters);

Easiest explanation - The condition given says that there is no return TYPE HENCE we can call the FUNCTION DIRECTLY. The object name should be mentioned with a dot operator to access its class members. Then the function name with parameters, if required, can be given.

7.

Which call is correct for public members of a nested class?(a) Can be called from object of enclosing class(b) Can be called within enclosing class only with direct names(c) Direct names should be used for the nested classes(d) Only with help of nested class object pointerThis question was addressed to me during an interview.This interesting question is from Public Member Functions topic in chapter Member Functions & its Types of Object Oriented Programming

Answer»

Correct answer is (a) Can be called from object of enclosing CLASS

Easiest explanation - The closest DEFINITION is that any PUBLIC MEMBER function of the nested class can be accessed with the help of enclosing class object. The nested class object pointer can be used only within the enclosing class. It’s not mandatory to use the MEMBERS of nested class only within the enclosing class.

8.

Which is not a proper way to access public members of a class?(a) Using object pointer with arrow operator(b) Using object of class in main function(c) Using object of class with arrow operator(d) Using object anywhere in the programThe question was asked by my college professor while I was bunking the class.This intriguing question comes from Public Member Functions in division Member Functions & its Types of Object Oriented Programming

Answer»

Right choice is (C) USING object of class with arrow operator

For explanation: The public members can be accessed ANYWHERE in the program using the object of the class. And if object pointer is USED, then arrow operator is used to access class members. If NORMAL object is used with arrow operator, an error will be generated.

9.

How many public members are allowed in a class?(a) Only 1(b) At most 7(c) Exactly 3(d) As many as requiredThe question was posed to me in class test.Question is from Public Member Functions in chapter Member Functions & its Types of Object Oriented Programming

Answer»

The CORRECT answer is (d) As many as required

Explanation: The NUMBER of PUBLIC members that can be defined in a class doesn’t have any limit. Though the programmer should not use too many functions, instead should use another class for more specific functions to reduce the READABILITY complexity.

10.

In java, which rule among the following is applicable?(a) Keyword public can’t be preceded with all the public members(b) Keyword public must be preceded with all the public members(c) Keyword public must be post mentioned the function declaration(d) Keyword public is not mandatoryI have been asked this question in an internship interview.My question is based upon Public Member Functions in chapter Member Functions & its Types of Object Oriented Programming

Answer»

The correct ANSWER is (b) Keyword PUBLIC must be preceded with all the public members

For explanation: The public members in java must be preceded with the keyword public. It must be mentioned with each public member, unlike C++ where we MENTION it only once. In java, each member must have explicit declaration of specifier type.

11.

Which syntax is applicable to declare public member functions in C++?(a) public: (b) public()(c) public void (d) public::I got this question in an international level competition.This interesting question is from Public Member Functions in section Member Functions & its Types of Object Oriented Programming

Answer»

Right option is (a) public:

The best I can EXPLAIN: The syntax in C++ MUST contain the public keyword followed by a colon. THEREAFTER, all the public members can be DECLARED. But in few other LANGUAGE, public have to be mentioned explicitly with each member.

12.

Which syntax among the following is correct for public member functions?(a) public::void functionName(parameters)(b) public void functionName(parameters)(c) public(void functionName(parameters))(d) public:-void functionName(Parameters)I got this question by my school teacher while I was bunking the class.This intriguing question originated from Public Member Functions topic in portion Member Functions & its Types of Object Oriented Programming

Answer»

Correct answer is (B) public void functionName(parameters)

The explanation is: The public member functions declaration must be MENTIONED with the KEYWORD public. The SYNTAX given is USED in java. Keyword public is followed by the usual function declaration.

13.

Which type of member functions get inherited in the same specifier in which the inheritance is done? (If private inheritance is used, those become private and if public used, those become public)(a) Private member functions(b) Protected member functions(c) Public member functions(d) All member functionsThis question was addressed to me during an interview.My question is from Public Member Functions topic in portion Member Functions & its Types of Object Oriented Programming

Answer»

The correct answer is (c) Public MEMBER FUNCTIONS

Explanation: The public member functions gets into the same specifier in which the inheritance is done. If PROTECTED members are INVOLVED in public inheritance, still those remain protected in the derived class but public members BECOME public on public inheritance and protected in protected inheritance.

14.

Which among the following is true for public member functions?(a) Public member functions doesn’t have a return type(b) Public member functions doesn’t have any security(c) Public member functions are declared outside the class(d) Public member functions can be called using object of classThis question was posed to me in examination.My doubt stems from Public Member Functions topic in section Member Functions & its Types of Object Oriented Programming

Answer»

Right answer is (d) Public MEMBER functions can be called using object of class

The EXPLANATION: The public member functions can be called using object of the class. The members can’t be declared OUTSIDE the class as those WOULD become non-member functions of the class. The functions have security as those can be accessed using the class object only.

15.

What are public member functions?(a) Functions accessible outside the class but not in derived class(b) Functions accessible outside the class directly(c) Functions accessible everywhere using object of class(d) Functions that can’t be accessed outside the classI have been asked this question during an internship interview.I'm obligated to ask this question of Public Member Functions in portion Member Functions & its Types of Object Oriented Programming

Answer»

Correct choice is (C) Functions accessible everywhere using OBJECT of class

The EXPLANATION is: The most suitable definition WOULD be that public member functions are accessible everywhere using object of the class. If derived CLASSES are using those, derived class object can be used to call those functions.

16.

If a function in java is declared private then it __________________(a) Can’t access the standard output(b) Can access the standard output(c) Can’t access any output stream(d) Can access only the output streamsI had been asked this question in final exam.Origin of the question is Private Member Functions in portion Member Functions & its Types of Object Oriented Programming

Answer»

The CORRECT answer is (b) Can access the standard OUTPUT

To EXPLAIN I would say: The private MEMBERS can access any standard input or output. There is no restriction on access to any input or output stream. And since standard input can also be USED hence only accessing the output stream is not true.

17.

Can main() function be made private?(a) Yes, always(b) Yes, if program doesn’t contain any classes(c) No, because main function is user defined(d) No, neverThis question was posed to me during an online interview.My question is taken from Private Member Functions in portion Member Functions & its Types of Object Oriented Programming

Answer»

Correct choice is (d) No, never

To explain: The reason GIVEN in option “No, because main function is USER defined” is wrong. The proper reason that the main function should not be private is that it should be ACCESSIBLE in whole PROGRAM. This MAKES the program flexible.

18.

Which error will be produced if private members are accessed?(a) Can’t access private message(b) Code unreachable(c) Core dumped(d) Bad codeI have been asked this question by my college director while I was bunking the class.Question is taken from Private Member Functions topic in chapter Member Functions & its Types of Object Oriented Programming

Answer»

The CORRECT choice is (a) Can’t access private message

The best explanation: The private MEMBERS access from outside the CLASS produce an error. The error states that the code at some LINE can’t access the private members. And DENIES the access terminating the program.

19.

A private function of a derived class can be accessed by the parent class.(a) True(b) FalseI had been asked this question in an online quiz.I'm obligated to ask this question of Private Member Functions topic in division Member Functions & its Types of Object Oriented Programming

Answer» CORRECT OPTION is (b) False

To explain: If private functions GET accessed even by the parent class that will violate the rules of private members. If the functions can be accessed then the derived class SECURITY is hindered.
20.

If private members are to be called outside the class, which is a good alternative?(a) Call a public member function which calls private function(b) Call a private member function which calls private function(c) Call a protected member function which calls private function(d) Not possibleThe question was posed to me in an international level competition.My question is from Private Member Functions topic in division Member Functions & its Types of Object Oriented Programming

Answer»

Correct option is (a) Call a public member function which calls private function

For EXPLANATION: The private member FUNCTIONS can be accessed within the class. A public member function can be called which in TURN calls the private member function. This maintains the security and adheres to the rules of private members.

21.

Which function among the following can’t be accessed outside the class in java in same package?(a) public void show()(b) void show()(c) protected show()(d) static void show()I have been asked this question in exam.I need to ask this question from Private Member Functions in division Member Functions & its Types of Object Oriented Programming

Answer»

The CORRECT OPTION is (c) protected SHOW()

For explanation: The protected members are available within the CLASS. And are also available in DERIVED classes. But these members are treated as private members for outside the class and inheritance structure. Hence can’t be accessed.

22.

Private member functions ____________(a) Can’t be called from enclosing class(b) Can be accessed from enclosing class(c) Can be accessed only if nested class is private(d) Can be accessed only if nested class is publicThe question was asked in semester exam.My doubt stems from Private Member Functions topic in division Member Functions & its Types of Object Oriented Programming

Answer»

Right option is (a) Can’t be called from ENCLOSING CLASS

Easiest EXPLANATION - The NESTED class members can’t be accessed in the enclosed class even THOUGH other members can be accessed. This is to ensure the class members security and not to go against the rules of private members.

23.

How many private member functions are allowed in a class?(a) Only 1(b) Only 7(c) Only 255(d) As many as requiredI had been asked this question in my homework.I would like to ask this question from Private Member Functions in division Member Functions & its Types of Object Oriented Programming

Answer»

Correct option is (d) As MANY as required

The explanation is: There are no conditions applied on the NUMBER of private member functions that can be declared in a class. THOUGH the system may restrict use of too many functions depending on MEMORY.

24.

How to access a private member function of a class?(a) Using object of class(b) Using object pointer(c) Using address of member function(d) Using class addressThe question was asked in an online quiz.This interesting question is from Private Member Functions topic in division Member Functions & its Types of Object Oriented Programming

Answer»

Right option is (C) Using address of MEMBER FUNCTION

To explain I would say: Even the private member functions can be called outside the class. This is POSSIBLE if address of the function is KNOWN. We can use the address to call the function outside the class.

25.

In java, which rule must be followed?(a) Keyword private preceding list of private member’s(b) Keyword private with a colon before list of private member’s(c) Keyword private with arrow before each private member(d) Keyword private preceding each private memberI had been asked this question at a job interview.My question is based upon Private Member Functions in division Member Functions & its Types of Object Oriented Programming

Answer»

The correct option is (d) Keyword private preceding each private member

The BEST I can explain: The private keyword must be MENTIONED before each private member. UNLIKE the RULE in C++ to specify private once and LIST all other private member’s, in java all member declarations must be preceded by the keyword private.

26.

If private member functions are to be declared in C++ then _____________(a) private: (b) private (c) private(private member list)(d) private :- This question was addressed to me by my school principal while I was bunking the class.Question is taken from Private Member Functions topic in section Member Functions & its Types of Object Oriented Programming

Answer» RIGHT answer is (a) private: MEMBERS>

To EXPLAIN I WOULD say: The private members doesn’t have to have the keyword with each private member. We only have to specify the keyword private followed by single COLON and then private member’s are listed.
27.

Which syntax among the following shows that a member is private in a class?(a) private: functionName(parameters)(b) private(functionName(parameters))(c) private functionName(parameters)(d) private::functionName(parameters)I have been asked this question in semester exam.My question is based upon Private Member Functions topic in section Member Functions & its Types of Object Oriented Programming

Answer»

Right option is (c) PRIVATE functionName(parameters)

Best explanation: The function declaration must contain private keyword FOLLOWER by the return type and function name. Private keyword is followed by NORMAL function declaration.

28.

Which member can never be accessed by inherited classes?(a) Private member function(b) Public member function(c) Protected member function(d) All can be accessedI have been asked this question in an international level competition.My query is from Private Member Functions in chapter Member Functions & its Types of Object Oriented Programming

Answer»

Correct OPTION is (a) Private member function

To explain: The private member FUNCTIONS can never be accessed in the derived classes. The ACCESS specifiers is of MAXIMUM security that allows only the MEMBERS of self class to access the private member functions.

29.

Which among the following is true?(a) The private members can’t be accessed by public members of the class(b) The private members can be accessed by public members of the class(c) The private members can be accessed only by the private members of the class(d) The private members can’t be accessed by the protected members of the classI have been asked this question in an internship interview.The doubt is from Private Member Functions topic in chapter Member Functions & its Types of Object Oriented Programming

Answer»

Right ANSWER is (b) The private members can be accessed by public members of the CLASS

Easiest explanation - The private members are accessible within the class. There is no RESTRICTION on use of private members by public or PROTECTED members. All the members can access the private MEMBER functions of the class.

30.

Which is private member functions access scope?(a) Member functions which can only be used within the class(b) Member functions which can used outside the class(c) Member functions which are accessible in derived class(d) Member functions which can’t be accessed inside the classThe question was asked in an online quiz.Question is taken from Private Member Functions in division Member Functions & its Types of Object Oriented Programming

Answer» RIGHT answer is (a) MEMBER functions which can only be used within the class

Easy explanation - The member functions can be accessed inside the class only if they are PRIVATE. The access is scope is limited to ensure the SECURITY of the private MEMBERS and their usage.
31.

Use of const member function in a program _________________________(a) Is mandatory, always(b) Is optional, always(c) Is mandatory, if objects are used(d) Is optional, if const objects are usedThe question was asked during an internship interview.This intriguing question originated from Constant Member Functions in chapter Member Functions & its Types of Object Oriented Programming

Answer»

Correct CHOICE is (b) Is optional, always

Explanation: The use of CONST MEMBER functions is not mandatory. If const objects are involved then there is a HIGH use of const member functions too. But there is no mandatory CONDITION.

32.

Which among the following is recommended for const functions?(a) Const function use should be reduced in a program(b) Const function use should be more in a program(c) Const function use should not matter in a program(d) Const function use should be able to modify the valuesI have been asked this question during an online exam.Origin of the question is Constant Member Functions topic in portion Member Functions & its Types of Object Oriented Programming

Answer» RIGHT option is (B) Const function use should be more in a program

For explanation: The const member FUNCTIONS should be used more in a program. The REASON behind is to ensure there is no accidental modification of data of object. Also to ensure any unintended modification which may result in unexpected termination of program.
33.

If const version of a function when overloading is used, the function ___________________(a) Returns reference to object(b) Returns volatile reference(c) Returns mutable reference(d) Returns const referenceI had been asked this question by my college professor while I was bunking the class.I need to ask this question from Constant Member Functions in section Member Functions & its Types of Object Oriented Programming

Answer»

Correct option is (d) Returns const reference

The EXPLANATION is: The FUNCTION returns a const reference. This is to ensure that the value of object CALLING the function is not modified. This is a security feature.

34.

Functions which differ in const-ness are considered ______________________(a) To have same signature(b) To have different signature(c) To produce compile time error(d) To produce runtime errorI have been asked this question during an interview.This intriguing question comes from Constant Member Functions in portion Member Functions & its Types of Object Oriented Programming

Answer»

Correct answer is (B) To have different signature

The best I can explain: The FUNCTIONS are CONSIDERED to have different signature. This is because the const-ness also defines the type of function or the working of functions. And HENCE the functions can be considered different. This is the reason that we can use function overloading for const and non-const version of same function.

35.

If a function is to be made const, which is the correct syntax?(a) const functionName(parameters);(b) const returnType functionName(parameters);(c) const functionName(returnType)(Parameters);(d) const (functionName(parameters));This question was addressed to me in an interview.This question is from Constant Member Functions in division Member Functions & its Types of Object Oriented Programming

Answer»

Right option is (b) const RETURNTYPE FUNCTIONNAME(parameters);

To explain I would say: The function declaration must contain the keyword const. The const keyword makes the function const type. The usual function declaration can be GIVEN followed by the keyword. The keyword const can be given after the declaration of function and before DEFINITION.

36.

When both the const and non-const version of functions are required?(a) Return value have to be different in const(b) Return value have to be same in const(c) Return values have to be ignored(d) Return values have to be suppressedI had been asked this question during an interview.My doubt stems from Constant Member Functions topic in section Member Functions & its Types of Object Oriented Programming

Answer»

Correct answer is (a) RETURN value have to be different in const

The explanation is: The return values can help to overload the functions. ALSO, this will allow us to USE a non-const function to be CALLED INSIDE both the const and non-const version of functions.

37.

How is it possible to have both const and non-const version of a function?(a) Function overriding(b) Function prototyping(c) Function overloading(d) Function declaringThis question was addressed to me by my school principal while I was bunking the class.This intriguing question comes from Constant Member Functions in portion Member Functions & its Types of Object Oriented Programming

Answer»

Correct answer is (c) Function overloading

The best I can EXPLAIN: The FUNCTIONS can be declared CONST and non-const in the same program. The TECHNIQUE USED is function overloading. We can define a const function and then a non-const version of same function using overloading.

38.

A function can have both the const and non-const version in the same program.(a) True(b) FalseI got this question in an interview.I want to ask this question from Constant Member Functions topic in portion Member Functions & its Types of Object Oriented Programming

Answer»

Correct option is (a) True

Explanation: The functions in a program can be made both const and non-const. This FEATURE is made available to make programming more flexible. This ENSURES the security too as we can CALL const FUNCTION whenever required.

39.

Can a constructor function be constant?(a) Yes, always(b) Yes, only if permissions are given(c) No, because objects are not involved(d) No, neverThe question was asked in homework.The above asked question is from Constant Member Functions topic in portion Member Functions & its Types of Object Oriented Programming

Answer»

Right CHOICE is (d) No, never

Best explanation: The constructors can’t be MADE const. This is to ensure that the constructor is CAPABLE of initializing the values to the members of the object. If it is made constant then it won’t be able to INITIALIZE any data member values.

40.

If a const object calls a non-const member function then ____________________(a) Run time error may get produced(b) Compile time error may get produced(c) Either compile time or run time error is produced(d) The program can’t be compiledThe question was asked in an online interview.This key question is from Constant Member Functions in chapter Member Functions & its Types of Object Oriented Programming

Answer»

Right OPTION is (b) Compile TIME error may get PRODUCED

Easiest explanation - The program gets compiled but produces an error. The error is produced because a constant value is being CHANGED. Even if there is no code that can change any object value, but non-const MEMBER functions are assumed to change the values.

41.

Which is the correct condition on const member functions?(a) Const member functions can’t call non-const member functions(b) Const member functions can’t call any other function(c) Const member functions can call only the functions which are neither const nor non-const(d) Const member functions can call only data members of call not member functionsI had been asked this question in homework.My question is taken from Constant Member Functions in portion Member Functions & its Types of Object Oriented Programming

Answer»

Right answer is (a) CONST member FUNCTIONS can’t CALL non-const member functions

Best explanation: The const member functions are RESTRICTED to call any other non-const member functions. This is to ensure that the const FUNCTION doesn’t have any code that might modify the calling object.

42.

Non-const functions _______________________(a) Can be called only from non-const object(b) Can be called only from const object(c) Can be called both by const and non-const object(d) Can’t be called with objectThis question was addressed to me in a national level competition.My doubt is from Constant Member Functions topic in section Member Functions & its Types of Object Oriented Programming

Answer»

Correct option is (a) Can be called only from non-const object

The best I can explain: The non-const functions are able to modify the values of object which called the function. So only the non-const functions can be called. If const object is used then the COMPILER PRODUCES an error as the const object is being GIVEN to a function which can modify its values.

43.

Which objects can call the const functions?(a) Only const objects(b) Only non-const objects(c) Both const and non-const objects(d) Neither const not non-const objectsThis question was posed to me in examination.The origin of the question is Constant Member Functions topic in portion Member Functions & its Types of Object Oriented Programming

Answer»

Correct choice is (C) Both const and NON-const objects

For EXPLANATION: All the objects of a class can CALL const functions for its use. Const objects can call the const functions to SINCE those values are already constant. And the non- const objects can call the const functions to keep their values constant.

44.

Which keyword must be used to declare a member function as a constant member function?(a) Constant(b) Const(c) FunctionConst(d) UnchangedThe question was posed to me during an interview for a job.My enquiry is from Constant Member Functions topic in division Member Functions & its Types of Object Oriented Programming

Answer»

The correct option is (B) Const

To explain: The keyword const is PROVIDED in most of the programming languages. This indicates that the member on which it is specified remains constant with the respective VALUES of members. The keyword MUST be mentioned so as to declare a member FUNCTION to be constant.

45.

What are the constant member functions?(a) Functions which doesn’t change value of calling object(b) Functions which doesn’t change value of any object inside definition(c) Functions which doesn’t allow modification of any object of class(d) Functions which doesn’t allow modification of argument objectsThe question was posed to me in an online quiz.Question is from Constant Member Functions in portion Member Functions & its Types of Object Oriented Programming

Answer»

The correct OPTION is (a) Functions which doesn’t change VALUE of calling OBJECT

Easy explanation - The constant member functions are a special type of member functions. These are intended to restrict any modification in to the values of object which is USED to invoke that function. This is done to ENSURE that there are no accidental modifications to the object.

46.

Which feature of OOP is exhibited by the function overriding?(a) Inheritance(b) Abstraction(c) Polymorphism(d) EncapsulationI have been asked this question during a job interview.This intriguing question originated from Overriding Member Functions topic in chapter Member Functions & its Types of Object Oriented Programming

Answer»

Right option is (C) Polymorphism

To explain: The polymorphism feature is exhibited by function OVERRIDING. Polymorphism is the feature which basically DEFINES that same NAMED functions can have more than one functionalities.

47.

If virtual functions are defined in the base class then _______________(a) It is not necessary for derived classes to override those functions(b) It is necessary for derived classes to override those functions(c) Those functions can never be derived(d) Those functions must be overridden by all the derived classesI had been asked this question during an interview.This interesting question is from Overriding Member Functions in division Member Functions & its Types of Object Oriented Programming

Answer»

Correct choice is (a) It is not necessary for DERIVED CLASSES to override those functions

To explain I would say: The derived classes doesn’t have to REDEFINE and override the base class functions. If one DEFINITION is already given it is not mandatory for any derived class to override those functions. The base class definition will be used.

48.

Abstract functions of a base class _________________(a) Are overridden by the definition in same class(b) Are overridden by the definition in parent class(c) Are not overridden generally(d) Are overridden by the definition in derived classThis question was addressed to me by my school teacher while I was bunking the class.The origin of the question is Overriding Member Functions topic in section Member Functions & its Types of Object Oriented Programming

Answer»

The correct answer is (d) Are overridden by the definition in derived CLASS

Easiest explanation - The functions declared to be abstract in BASE class are redefined in derived CLASSES. That is, the functions are overridden by the definitions given in the derived classes. This must be DONE to GIVE at least one definition to each undefined function.

49.

In Kotlin, the function to be overridden must be ______________(a) Private(b) Open(c) Closed(d) AbstractThe question was posed to me by my school teacher while I was bunking the class.My query is from Overriding Member Functions topic in chapter Member Functions & its Types of Object Oriented Programming

Answer»

Correct option is (b) Open

Explanation: The FUNCTION to be OVERRIDDEN must be open. This is a condition in KOTLIN for any function to be overridden. This avoids accidental overriding.

50.

What should be used to call the base class method from the derived class if function overriding is used in Java?(a) Keyword super(b) Scope resolution(c) Dot operator(d) Function name in parenthesisI have been asked this question during an interview for a job.My question is based upon Overriding Member Functions in section Member Functions & its Types of Object Oriented Programming

Answer»

Correct CHOICE is (a) KEYWORD super

The best I can explain: The keyword super must be used to ACCESS base CLASS members. Even when overriding is used, super must be used with the dot operator. The overriding is possible.