Ask Question
13 April, 02:50

Which of the following statements is true?

Constructors can specify parameters and return types.

Constructors can specify parameters but not return types.

Constructors cannot specify parameters but can specify return types.

Constructors can specify neither parameters not return types.

+1
Answers (1)
  1. 13 April, 06:14
    0
    Answer: Constructors can specify parameters but not return types.

    Explanation:

    public class Student {

    int roll_no;

    public Student (int a) {

    roll_no = a;

    }

    public static void main (String[] args) {

    Student abs = new Student (10);

    System. out. println (abc. roll_no);

    }

    }

    In the above code we have illustrated the working of constructors. We have a class with the name Student. then a constructor is created of the class called as the class constructor. In the main we create an object of the class and with this object we invoke the constructor and also pass a parameter. Here in the code we are passing the roll no of the student.

    So we can say that constructor is called during the runtime when the object created invokes the constructor so a constructor can have many arguments but it does not have a return type.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Which of the following statements is true? Constructors can specify parameters and return types. Constructors can specify parameters but ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers