I don't know if can't understand this question because I'm new to programming, or that the question is phrased weird.
I'm familiar with what a constructor is, and understand the first sentence of the question.
I've googled the question but can't find any answers. I just really don't understand what the question is asking from me.
---- edit -------
This would be the first part of the question. Now I don't know what to do with the next.
public class Constructor {
private String name;
private int age;
public Constructor(String name, int age) {
this.name = name;
this.age = age;
}
}
----- edit ----
So, after reading your comments I tried this. It works, but I'm not sure if it answers the question still. (It's a question from a textbook, and not my phrasing)
public class Account {
private String name;
private String balance;
public Account(String name, String balance) {
this.name = name;
this.balance = balance;
}
public Account() {
this.name = "Joseph bouff";
this.balance = "Will greir";
}
public void setName(String name) {
this.name = name;
}
public String getName() {
return name;
}
public void setBalance(String balance) {
this.balance = balance;
}
public String getBalance() {
return balance;
}
}
public class AccountTest {
public static void main(String[] args) {
Account account1 = new Account("Jane Green", "Paul goodman");
Account account2 = new Account();
System.out.println(account1.getName() + " " + account1.getBalance());
System.out.println(account2.getName() + " " + account2.getBalance());
}
}