- A It would lead to ambiguity and confusion during method resolution.
- B It violates the principles of object-oriented programming.
- C Java does not support dynamic dispatch based on return types.
- D All of the above.
- Share this MCQ
Answer:
D
Share this MCQ
Method overloading in Java is not possible by changing the return type of the method because it would lead to ambiguity and confusion during method resolution. This is because the compiler would not be able to decide which method to call at runtime if two methods with the same name and different return types exist. Moreover, it would also violate the principles of object-oriented programming, as the same method name would be used for different purposes. Furthermore, Java does not support dynamic dispatch based on return types, which means that the compiler would not be able to determine the correct method to call at runtime.
Click me to Read more Question & Answer of Java Interviews MCQsShare this MCQ