public class Dog {
private String name;
public void Dog(String n) {
name = n;
}
}What is wrong?
- A
Constructors cannot accept parameters
- B
Nothing is wrong
- Ccheck_circle
Constructors have no return type, not even void
- D
name should be public
Explanation
Including void makes Dog a regular method, not a constructor; remove void so it has no return type.