InterviewSolution
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 |
|
| 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 |
|
| 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 |
|
| 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 |
|
| 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); |
|
| 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 |
|
| 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 |
|
| 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 |
|
| 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 |
|
| 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: |
|
| 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) |
|
| 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 |
|
| 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 |
|
| 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 |
|
| 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 |
|
| 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 |
|
| 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 |
|
| 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 |
|
| 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() |
|
| 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 |
|
| 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 |
|
| 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 |
|
| 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 |
|
| 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: 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) |
|
| 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 |
|
| 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 |
|
| 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 |
|
| 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 |
|
| 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 |
|
| 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); |
|
| 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 |
|
| 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 |
|
| 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 |
|
| 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 |
|
| 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 |
|
| 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 |
|
| 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 |
|
| 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 |
|
| 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 |
|
| 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 |
|
| 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 |
|
| 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 |
|
| 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 |
|
| 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 |
|
| 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 |
|