Which three lines, when inserted independently at line n1, cause the program to print a o balance?

Given the following class:

And given the following main method, located in another class:

Which three lines, when inserted independently at line n1, cause the program to print a o balance?
A. this.amount = 0;
B. amount = 0;
C. acct (0) ;
D. acct.amount = 0;
E. acct. getAmount () = 0;
F. acct.changeAmount(0);
G. acct.changeAmount(-acct.amount);
H. acct.changeAmount(-acct.getAmount());

Download Printable PDF. VALID exam to help you PASS.

2 thoughts on “Which three lines, when inserted independently at line n1, cause the program to print a o balance?

  1. public class Q135Account {
    int amount;
    Q135Account(int amount){
    this.amount=amount;
    }

    public int getAmount() {
    return amount;
    }
    void changeAmount(int x){
    amount +=x;
    }

    public static void main(String[] args) {
    Q135Account acct = new Q135Account((int)(Math.random()*1000));
    // D acct.amount=0;
    // G acct.changeAmount(-acct.amount);
    // H acct.changeAmount(-acct.getAmount());
    System.out.println(acct.getAmount());

    }
    }

  2. DGH. D directly assign amount. G, change amount to sum its own amount but negative and H likewise

Leave a Reply

Your email address will not be published.