Which of the following statements about constructor overloading in Java is correct?
- Constructor overloading allows a class to have multiple constructors with the same name but different parameters.
- Constructor overloading is not supported in Java.
- Constructor overloading requires that all constructors have the same number of parameters.
- Constructor overloading can only be used in abstract classes.
a) is correct. Constructor overloading in Java enables a class to have multiple constructors with the same name but different parameters. This allows for creating objects with various initializations. b) and d) are incorrect statements. c) is also incorrect because the number of parameters can vary among overloaded constructors.
Loading...
Related Quiz
- In which case(s) does Binary Search perform in O(1) time complexity?
- How does intrinsic locking in synchronized methods/blocks ensure thread safety?
- Consider a scenario where a superclass method that throws an exception is overridden in the subclass. How should the exception handling be approached in this case, ensuring that the application's robustness is maintained?
- Why does Java not support operator overloading?
- The method ________ of FileOutputStream class is used to write a specific byte of data to a file output stream.