Question: what is the output of this java code? public class Account { private double balance; public Account() { } public Account(int id, double balance) {
what is the output of this java code?
public class Account {
private double balance;
public Account() { }
public Account(int id, double balance) {
if (balance > 0.0)
this.balance = balance;
else
this.balance=0.0; }
public void setBalance(double balance) {
this.balance = balance; }
public String toString(){
return(" Your updated balance is " + balance); }
}
public class Client extends Account {
private int id;
public Client() { }
public Client(int id, double balance) {
super(balance);
this.id = id; }
public String toString(){
return ("Th Client ID is:"+id+ super.toString()); }
}
public class TestAccount {
public static void main(String[] args) {
Client MyAccount1= new Account(1,-19);
Client MyAccount2= new Account(2,100);
System.out.println(MyAccount2);
System.out.println(MyAccount1);
}
}
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
