

MCQOPTIONS
Saved Bookmarks
This section includes 18 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. |
A static nested class is _____________ class in behavior that is nested in another _________ class. |
A. | Top level, top level |
B. | Top level, low level |
C. | Low level, top level |
D. | Low level, low level |
Answer» B. Top level, low level | |
2. |
If a declaration of a member in inner class has the same name as that in the outer class, then ________________ enclosing scope. |
A. | Outer declaration shadows inner declaration in |
B. | Inner declaration shadows outer declaration in |
C. | Declaration gives compile time error |
D. | Declaration gives runtime error |
Answer» C. Declaration gives compile time error | |
3. |
How to create object of the inner class? |
A. | OuterClass.InnerClass innerObject = outerObject.new InnerClass(); |
B. | OuterClass.InnerClass innerObject = new InnerClass(); |
C. | InnerClass innerObject = outerObject.new InnerClass(); |
D. | OuterClass.InnerClass = outerObject.new InnerClass(); |
Answer» B. OuterClass.InnerClass innerObject = new InnerClass(); | |
4. |
A nested class can have its own static members. |
A. | True |
B. | False |
Answer» C. | |
5. |
How to access static nested classes? |
A. | OuterClass.StaticNestedClass |
B. | OuterClass->StaticNestedClass |
C. | OuterClass(StaticNestedClass) |
D. | OuterClass[StaticNestedClass] |
Answer» B. OuterClass->StaticNestedClass | |
6. |
Which among the following is the correct advantage/disadvantage of nested classes? |
A. | Makes the code more complex |
B. | Makes the code unreadable |
C. | Makes the code efficient and readable |
D. | Makes the code multithreaded |
Answer» D. Makes the code multithreaded | |
7. |
Use of nested class ____________ encapsulation. |
A. | Increases |
B. | Decreases |
C. | Doesn’t affect |
D. | Slightly decreases |
Answer» B. Decreases | |
8. |
The nested class can be declared ___________________ |
A. | Public |
B. | Private |
C. | Protected |
D. | Public, Protected, Private or Package private |
Answer» E. | |
9. |
Static nested classes doesn’t have access to _________________ from enclosing class. |
A. | Private members |
B. | Protected members |
C. | Public members |
D. | Any other members |
Answer» E. | |
10. |
Non-static nested classes have access to _____________ from enclosing class. |
A. | Private members |
B. | Protected members |
C. | Public members |
D. | All the members |
Answer» E. | |
11. |
How many categories are nested classes divided into? |
A. | 2 |
B. | 3 |
C. | 4 |
D. | 5 |
Answer» B. 3 | |
12. |
Which feature of OOP reduces the use of nested classes? |
A. | Encapsulation |
B. | Inheritance |
C. | Binding |
D. | Abstraction |
Answer» C. Binding | |
13. |
Which among the following best describes a nested class? |
A. | Class inside a class |
B. | Class inside a function |
C. | Class inside a package |
D. | Class inside a structure |
Answer» B. Class inside a function | |
14. |
HOW_TO_ACCESS_STATIC_NESTED_CLASSES??$ |
A. | OuterClass.StaticNestedClass |
B. | OuterClass->StaticNestedClass |
C. | OuterClass(StaticNestedClass) |
D. | OuterClass[StaticNestedClass]. |
Answer» B. OuterClass->StaticNestedClass | |
15. |
How to create object of the inner class?$ |
A. | OuterClass.InnerClass innerObject = outerObject.new InnerClass(); |
B. | OuterClass.InnerClass innerObject = new InnerClass(); |
C. | InnerClass innerObject = outerObject.new InnerClass(); |
D. | OuterClass.InnerClass = outerObject.new InnerClass(); |
Answer» B. OuterClass.InnerClass innerObject = new InnerClass(); | |
16. |
A_nested_class_can_have_its_own_static_members.$ |
A. | True |
B. | False |
Answer» C. | |
17. |
Instance of inner class can exist only _______________ enclosing class. |
A. | Within |
B. | Outside |
C. | Private to |
D. | Public to |
Answer» C. Private to | |
18. |
Static nested classes doesn’t have access to _________________ from enclosing class.$ |
A. | Private members |
B. | Protected members |
C. | Public members |
D. | Any other members |
Answer» E. | |