192k views
4 votes
Given a class named student, which of the following is a valid constructor declaration for the class?

(a) Student (student s) { }
(b) Student student ( ) { }
(c) Private final student ( ) { }
(d) Void student ( ) { }
(e) Static void student(){ }.

1 Answer

5 votes

Final answer:

The valid constructor declaration for the class named 'student' is option (b) Student student () { }.

Step-by-step explanation:

The valid constructor declaration for the class named student is option (b) Student student () { }.

The constructor declaration must:

Option (b) meets all these requirements by having the same name as the class (student), not having any explicit return type, and accepting zero parameters.

User MandyK
by
7.7k points