This document contains two sets of multiple choice questions about object-oriented programming concepts. The first set focuses on private member functions, covering topics like their access scope, how they can be accessed from within and outside a class, and their syntax declaration. The second set focuses on catching class types, with questions about catching exceptions from base and derived classes and how their catch blocks should be ordered.
This document contains two sets of multiple choice questions about object-oriented programming concepts. The first set focuses on private member functions, covering topics like their access scope, how they can be accessed from within and outside a class, and their syntax declaration. The second set focuses on catching class types, with questions about catching exceptions from base and derived classes and how their catch blocks should be ordered.
This document contains two sets of multiple choice questions about object-oriented programming concepts. The first set focuses on private member functions, covering topics like their access scope, how they can be accessed from within and outside a class, and their syntax declaration. The second set focuses on catching class types, with questions about catching exceptions from base and derived classes and how their catch blocks should be ordered.
This document contains two sets of multiple choice questions about object-oriented programming concepts. The first set focuses on private member functions, covering topics like their access scope, how they can be accessed from within and outside a class, and their syntax declaration. The second set focuses on catching class types, with questions about catching exceptions from base and derived classes and how their catch blocks should be ordered.
Download as DOCX, PDF, TXT or read online from Scribd
Download as docx, pdf, or txt
You are on page 1of 5
This set of Object Oriented Programming Multiple Choice Questions & Answers focuses on
“Private Member Functions”.
1. 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 class View Answer 2. 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 class View Answer 3. 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 accessed View Answer 4. 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) View Answer 5. If private member functions are to be declared in C++ then _____________ a) private: <all private members> b) private <member name> c) private(private member list) d) private :- <private members> View Answer 6. 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 member View Answer 7. How many private member functions are allowed in a class? a) Only 1 b) Only 7 c) Only 255 d) As many as required View Answer 8. 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 address View Answer 9. 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 public View Answer 10. 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() View Answer 11. 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 possible View Answer 12. A private function of a derived class can be accessed by the parent class. a) True b) False View Answer 13. Which error will be produced if private members are accessed? a) Can’t access private message b) Code unreachable c) Core dumped d) Bad code View Answer 14. 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, never View Answer 15. 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 streams View Answer This set of Object Oriented Programming (OOPs) Multiple Choice Questions & Answers (MCQs) focuses on “Catching Class Types”.
1. Which among the following is true for class exceptions?
a) Only base class can give rise to exceptions b) Only derived class can give rise to exceptions c) Either base class or derived class may produce exceptions d) Both base class and derived class may produce exceptions View Answer 2. If both base and derived class caught exceptions ______________ a) Then catch block of derived class must be defined before base class b) Then catch block of base class must be defined before the derived class c) Then catch block of base and derived classes doesn’t matter d) Then catch block of base and derived classes are not mandatory to be defined View Answer 3. Which among the following is true? a) If catch block of base class is written first, it is compile time error b) If catch block of base class is written first, it is run time error c) If catch block of base class is written first, derived class catch block can’t be reached d) If catch block of base class is written first, only derived class catch block is executed View Answer 4. The catching of base class exception ___________________________ in java. a) After derived class is not allowed by compiler b) Before derived class is not allowed by compiler c) Before derived class is allowed d) After derived class can’t be done View Answer 5. If catching of base class exception is done before derived class in C++ ________________ a) It gives compile time error b) It doesn’t run the program c) It may give warning but not error d) It always gives compile time error View Answer 6. How many catch blocks can a class have? a) Only 1 b) 2 c) 3 d) As many as required View Answer 7. Since which version of java is multiple exception catch was made possible? a) Java 4 b) Java 5 c) Java 6 d) Java 7 View Answer 8. To catch more than one exception in one catch block, how are the exceptions separated in the syntax? a) Vertical bar b) Hyphen c) Plus d) Modulus View Answer 9. If a catch block accepts more than one exceptions then __________________ a) The catch parameters are not final b) The catch parameters are final c) The catch parameters are not defined d) The catch parameters are not used View Answer 10. Which among the following handles the undefined class in program? a) ClassNotFound b) NoClassException c) ClassFoundException d) ClassNotFoundException View Answer 11. If classes produce some exceptions, then ______________________ a) Their respective catch block must be defined b) Their respective catch blocks are not mandatory c) Their catch blocks should be defined inside main function d) Their catch blocks must be defined at the end of program View Answer 12. Which among the following is true? a) Only the base class catch blocks are important b) Only the derived class catch blocks are important c) Both the base and derived class catch blocks are important d) If base and derived classes both produce exceptions, program doesn’t run View Answer 13. Which is the necessary condition to define the base and derived class catch blocks? a) Base class catch should be defined first b) Derived class catch should be defined first c) Catch block for both the classes must not be defined d) Catch block must be defined inside main function View Answer 14. Only the base class catch box can handle more than one exception in single block. a) True b) False View Answer 15. Which condition among the following might result in memory exception? a) False if conditions b) Nested if conditions that are all false c) Infinite loops d) Loop that runs exactly 99 times View Answer https://www.sanfoundry.com/object-oriented-programming-questions-answers-catching-class-types/