

MCQOPTIONS
Saved Bookmarks
This section includes 21 Mcqs, each offering curated multiple-choice questions to sharpen your Java knowledge and support exam preparation. Choose a topic below to get started.
1. |
Which is the correct way of overriding a method throwing exceptions in Java? |
A. | void show() throws IOException{ } |
B. | void show() throws IOException{ } |
C. | void show() throws ArithmeticException{ } |
D. | None |
Answer» B. void show() throws IOException{ } | |
2. |
To successfully override a superclass method in Java, the access modifier of the method of the subclass can be ___ restrictive. |
A. | Less |
B. | More |
C. | Less or Same |
D. | None |
Answer» D. None | |
3. |
An Overridden method is the method of ____ class and the overriding method is the method of ___ class. |
A. | super, sub |
B. | sub, super |
C. | super, super |
D. | sub, sub |
Answer» B. sub, super | |
4. |
What are the advantages of Method Overriding in Java? |
A. | A subclass can add extra functionality to the overriding method. |
B. | A subclass can call both the overridden method and overriding method. |
C. | It supports polymorphism. A superclass reference can be used to call the common method of all subclasses. |
D. | All the above |
Answer» E. | |
5. |
Method overriding increases the burden on the JVM in terms of runtime checks and resolution. State TRUE or FALSE. |
A. | FALSE |
B. | TRUE |
C. | - |
D. | - |
Answer» C. - | |
6. |
A method of a Superclass can not override the method of the Subclass. State TRUE or FALSE. |
A. | TRUE |
B. | FALSE |
C. | - |
D. | - |
Answer» B. FALSE | |
7. |
If the method signature of a Superclass and the method signature of a Subclass are the same, then the subclass method is said to be _____ the superclass's method. |
A. | Overriding |
B. | Overloading |
C. | - |
D. | - |
Answer» B. Overloading | |
8. |
A failed method overriding calls the method of a ___ in Java. |
A. | Superclass |
B. | Subclass |
C. | Superclass or Subclass |
D. | None |
Answer» D. None | |
9. |
A successful Method Overriding calls the method of ___ in Java. |
A. | Superclass |
B. | Subclass |
C. | - |
D. | - |
Answer» C. - | |
10. |
Identify INVALID Java Method Overriding in the below code snippets? |
A. | void superclassMethod(int a, float b){ } |
B. | void superclassMethod(){ } |
C. | int superclassMethod(int a, float b){ } |
D. | None |
Answer» D. None | |
11. |
What is the output of the below Java program with Method Overriding and SUPER keyword? |
A. | Transmission AMT |
B. | Transmission Manual |
C. | Transmission Manual |
D. | Transmission AMT |
Answer» B. Transmission Manual | |
12. |
What is the output of the below Java program with Method Overriding? |
A. | Subclass Seats=20 |
B. | Superclass Seats=32 |
C. | Superclass Seats=32 |
D. | Subclass Seats=20 |
Answer» E. | |
13. |
The Method-Overloading and Method-Overriding are not the same. State TRUE or FALSE. |
A. | TRUE |
B. | FALSE |
C. | - |
D. | - |
Answer» B. FALSE | |
14. |
Why should a method be overridden in Java instead of writing a method with a different name? |
A. | Large projects heavily depend on inheritance |
B. | The code-base refers to the same method with the same method signature in different classes of the project |
C. | It is not possible to change the method calling code at all occurrences of the project. It may break the whole project. |
D. | All the above. |
Answer» E. | |
15. |
It is not mandatory to override all or a few methods of the Superclass. State TRUE or FALSE. |
A. | TRUE |
B. | FALSE |
C. | - |
D. | - |
Answer» B. FALSE | |
16. |
Method Overriding is useful to add extra functionality or code to a method of subclass with the same name as the inherited method. State TRUE or FALSE. |
A. | TRUE |
B. | FALSE |
C. | - |
D. | - |
Answer» B. FALSE | |
17. |
What is method overriding in Java? |
A. | Writing a method in a subclass with the same name of superclass's method |
B. | Mentioning the same return type of the method of the superclass |
C. | The argument list in the method of subclass and the method of superclass should be the same |
D. | All the above |
Answer» E. | |
18. |
THE_MODIFIER_USED_TO_HIDE_THE_BASE_CLASS_METHODS_IS??$ |
A. | Virtual |
B. | New |
C. | Override |
D. | Sealed |
Answer» C. Override | |
19. |
final, native, private |
A. | final, static, protected |
B. | final, private, abstract |
C. | final, static, public |
Answer» D. | |
20. |
What is the process of defining a method in a subclass having same name & type signature as a method in its superclass? |
A. | Method overloading |
B. | Method overriding |
C. | Method hiding |
D. | None of the mentioned |
Answer» C. Method hiding | |
21. |
Which of this keyword can be used in a subclass to call the constructor of superclass? |
A. | super |
B. | this |
C. | extent |
D. | extends |
Answer» B. this | |