Answer:
//Abstract class declaration of Account
public abstract class Account{
//nextId initialized to 10001
private static int nextId = 10001;
private int id;
private String name;
// constructor with one argument
public Account(String passName){
name = passName;
//assign the value of nextId to id
id = nextId;
//nextId is incremented
nextId++;
}
// accessor method to return id
public int getId(){
return id;
}
// accessor method to return name
public String getName(){
return name;
}
//abstract method that return object of type Cash
//It is not implemented here.
//It will be overriden and implemented by concrete subclassed
public abstract Cash getValue();
}
Step-by-step explanation:
The abstract class Account is defined with the keyword abstract. Then inside the class, we declared and initialized an integer static variable nextId, an instance variable id and a String instance variable name.
A constructor is then defined which accept one argument of a string passName.
Two accessor methods getId and getName are declared. getId return an integer id, while getName return a string name.
Finally, an abstract method getValue is declared with no implementation and it return an object of type Cash.