Can a constructor return a value in Java?
- Yes, a constructor can return a value, which is the default value of the class's primary data type.
- No, constructors cannot return values in Java.
- A constructor can return values, but only if it has the same name as the class.
- A constructor can return values, but they must be of type 'void.'
b) is correct. Constructors in Java cannot return values, and their return type is always 'void.' a), c), and d) are incorrect statements.
Loading...
Related Quiz
- A ________ is used to create a client socket in Java.
- The ______ interface is used when you want a task to return a value after execution in a thread.
- What is the purpose of a parameterized constructor in Java?
- The collect() method in the Stream API is a type of ________ operation.
- Considering threading, which collection class might introduce higher overhead in managing read and write access?