MCQOPTIONS
Saved Bookmarks
This section includes 20 Mcqs, each offering curated multiple-choice questions to sharpen your Object Oriented Programming knowledge and support exam preparation. Choose a topic below to get started.
| 1. |
Which among the following is the main advantage of using local classes? |
| A. | Make program more efficient |
| B. | Makes program execution faster |
| C. | Helps to add extra functionality to a function |
| D. | Helps to add more members to a function |
| Answer» D. Helps to add more members to a function | |
| 2. |
Can a function, other than the enclosing function of local class, access the class members? |
| A. | Yes, using object |
| B. | Yes, using direct call |
| C. | Yes, using pointer |
| D. | No, can’t access |
| Answer» E. | |
| 3. |
What is the scope of local class? |
| A. | Within the class only |
| B. | Within the function |
| C. | Within the program |
| D. | One time creation and live till end of program |
| Answer» C. Within the program | |
| 4. |
Can two different functions have local class with same name? |
| A. | Yes, since local |
| B. | No, names must be different |
| C. | No, scope doesn’t work here |
| D. | No, ambiguity arises |
| Answer» B. No, names must be different | |
| 5. |
All the data members of local class must be ___________ |
| A. | Defined with declaration |
| B. | Defined in constructor |
| C. | Declared and defined in constructor |
| D. | Declared using a member function |
| Answer» C. Declared and defined in constructor | |
| 6. |
How many local classes can be defined inside a single function? |
| A. | Only 1 |
| B. | Only 3 |
| C. | Only 5 |
| D. | As many as required |
| Answer» E. | |
| 7. |
Which language can use inheritance with local classes? |
| A. | Kotlin |
| B. | Java |
| C. | SmallTalk |
| D. | SAP ABAP |
| Answer» E. | |
| 8. |
The enclosing function has no special access to the members of the local class. |
| A. | True |
| B. | False |
| Answer» B. False | |
| 9. |
Can static variables be declared inside a local class? |
| A. | Yes, with public access specifier |
| B. | Yes, anywhere as required |
| C. | No, not possible in private access specifier |
| D. | No, not possible anyway |
| Answer» E. | |
| 10. |
Local classes can access the type names and enumerators defined by the enclosing function. |
| A. | True |
| B. | False |
| Answer» B. False | |
| 11. |
Which type of data can a local class access from the function in which it is defined? |
| A. | Static and extern |
| B. | Abstract and static |
| C. | Void and extern |
| D. | Const and static |
| Answer» B. Abstract and static | |
| 12. |
Can local class members access/use the general local variables (except static, abstract etc.) of the function in which it is defined? |
| A. | Yes, it can access with arrow operator |
| B. | No, it can’t access with dot operator |
| C. | Yes, it can access using dot operator |
| D. | No, it can’t access In anyway |
| Answer» E. | |
| 13. |
All member functions of a local class must be ___________ |
| A. | Defined outside class body |
| B. | Defined outside the function definition |
| C. | Defined inside the class body |
| D. | Defined at starting of program |
| Answer» D. Defined at starting of program | |
| 14. |
What are local classes? |
| A. | Classes declared inside a package |
| B. | Classes declared inside a function |
| C. | Classes declared inside a class |
| D. | Classes declared inside structure |
| Answer» C. Classes declared inside a class | |
| 15. |
WHICH_LANGUAGE_CAN_USE_INHERITANCE_WITH_LOCAL_CLASSES??$ |
| A. | Kotlin |
| B. | Java |
| C. | SmallTalk |
| D. | SAP ABAP |
| Answer» E. | |
| 16. |
All the data members of local class must be ___________$ |
| A. | Defined with declaration |
| B. | Defined in constructor |
| C. | Declared and defined in constructor |
| D. | Declared using a member function |
| Answer» C. Declared and defined in constructor | |
| 17. |
How_many_local_classes_can_be_defined_inside_a_single_function?$ |
| A. | Only 1 |
| B. | Only 3 |
| C. | Only 5 |
| D. | As many as required |
| Answer» E. | |
| 18. |
Can_two_different_functions_have_local_class_with_same_name? |
| A. | Yes, since local |
| B. | No, names must be different |
| C. | No, scope doesn’t work here |
| D. | No, ambiguity arises |
| Answer» B. No, names must be different | |
| 19. |
The enclosing function has no special access to the members of local class. (True/False? |
| A. | True |
| B. | False |
| Answer» B. False | |
| 20. |
All the member functions of local classes are __________ by default. |
| A. | Static |
| B. | Inline |
| C. | Abstract |
| D. | Virtual |
| Answer» D. Virtual | |