Java SE 8 Programmer 1Z0–808 Practice Full Test 1
© examsiri.com
Question : 2 of 84
Marks:
+1,
-0
Given the following two classes:
Any amount of electricity used by a customer (represented by an instance of the customer class) must contribute to the customer's bill (represented by the member variable bill) through the method use Electricity method. An instance of the customer class should never be able to tamper with or decrease the value of the member variable bill.
public class Customer {
ElectricAccount acct = new ElectricAccount();
public void useElectricity (double kWh) {
acct.addKWh(kWh);
}
}
public class ElectricAccount {
private double kWh;
private double rate = 0.07;
private double bill;
//line n1
}How should you write methods in the ElectricAccount class at line n1 so that the member variable bill is always equal to the value of the member variable kwh multiplied by the member variable rate? Any amount of electricity used by a customer (represented by an instance of the customer class) must contribute to the customer's bill (represented by the member variable bill) through the method use Electricity method. An instance of the customer class should never be able to tamper with or decrease the value of the member variable bill.
Go to Question: