Deal of The Day! Hurry Up, Grab the Special Discount - Save 25% - Ends In 00:00:00 Coupon code: SAVE25
Welcome to Pass4Success

- Free Preparation Discussions

Oracle 1Z0-808 Exam - Topic 18 Question 112 Discussion

Actual exam question for Oracle's 1Z0-808 exam
Question #: 112
Topic #: 18
[All 1Z0-808 Questions]

Given these 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 useElectricity method.

An instance of the Customer class should never be able to tamper with or decrease the value of the member variable bill.

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?

Show Suggested Answer Hide Answer
Suggested Answer: C

Contribute your Thoughts:

0/2000 characters
Rolf
4 months ago
I think Option C might work too, but not sure.
upvoted 0 times
...
Jesusa
4 months ago
Option A seems like the best choice here.
upvoted 0 times
...
Lezlie
4 months ago
Wait, can the Customer class really not touch the bill at all?
upvoted 0 times
...
Natalie
4 months ago
Totally agree, that makes sense!
upvoted 0 times
...
Yong
4 months ago
The bill should always be calculated as kwh * rate.
upvoted 0 times
...
Judy
5 months ago
I’m pretty sure we need to make the bill variable private and provide a way to calculate it based on kwh and rate. I just can't remember if it was a method or a property.
upvoted 0 times
...
Cecilia
5 months ago
I feel like the solution involves using a setter method for kwh that automatically updates the bill. But I can't recall the exact syntax we used in class.
upvoted 0 times
...
Eliseo
5 months ago
I think we practiced a similar question where we had to calculate a total based on different inputs. I’m a bit unsure about how to implement the method correctly here though.
upvoted 0 times
...
Karrie
5 months ago
I remember we discussed how to ensure encapsulation in our classes, especially with the bill variable. It shouldn't be directly modified by the Customer class.
upvoted 0 times
...
Amie
5 months ago
I think I've got a good strategy for this. I'll create a private method in the ElectricAccount class that calculates the bill based on the kwh and rate variables, and then use that method in the public useElectricity method to update the bill. That way, the Customer class can't tamper with the bill directly.
upvoted 0 times
...
Samira
5 months ago
This seems straightforward enough. I'll just need to create a method in the ElectricAccount class that multiplies the kwh and rate variables to calculate the bill, and then make sure the Customer class can't directly access or modify the bill variable.
upvoted 0 times
...
Reena
5 months ago
I'm a bit confused on how to approach this. I'll need to review the class definitions and requirements again to make sure I understand the problem fully before trying to write any code.
upvoted 0 times
...
Rachael
5 months ago
Okay, I think I've got a plan. I'll need to create a method in the ElectricAccount class that calculates the bill based on the kwh and rate variables, and then make sure the Customer class can't directly modify the bill variable.
upvoted 0 times
...
King
5 months ago
Hmm, this looks like a tricky one. I'll need to carefully read through the requirements and think about how to implement the useElectricity method in the ElectricAccount class to ensure the bill is always calculated correctly.
upvoted 0 times
...
Galen
10 months ago
I'm stumped. Maybe I should just become an electrician instead - no complicated billing rules to worry about!
upvoted 0 times
...
Cristy
10 months ago
Option C looks like it would work, but it's a bit too open-ended. I prefer the more controlled approach of Option B to keep the bill calculation secure.
upvoted 0 times
Billye
9 months ago
I see your point about Option C being open-ended. Option B does seem like a better choice for maintaining security in the bill calculation.
upvoted 0 times
...
Tori
9 months ago
I think Option A might be too restrictive, so I also lean towards Option B for a more controlled approach.
upvoted 0 times
...
Gary
9 months ago
I agree, Option B seems like the safer choice to ensure the bill calculation remains secure.
upvoted 0 times
...
...
Chantell
11 months ago
Haha, good one! Option A would be like letting the customer be the accountant. Might as well just give them the keys to the vault!
upvoted 0 times
Joana
10 months ago
Option A is a no-go. We need to keep the bill in check, no customer tampering allowed.
upvoted 0 times
...
Margery
10 months ago
I agree, giving customers control over the bill is a bad idea. Option A is definitely out.
upvoted 0 times
...
Destiny
10 months ago
Yeah, Option A sounds risky. We can't let customers mess with the bill.
upvoted 0 times
...
...
Lelia
11 months ago
I'm going with Option D. Encapsulating the bill calculation within the ElectricAccount class ensures the integrity of the data and prevents the customer from making unauthorized changes.
upvoted 0 times
...
Craig
11 months ago
Option B seems the most logical choice to enforce the requirement that the customer's bill cannot be tampered with. The method should allow updating the bill based on the electricity usage, but not allow the customer to directly modify the bill value.
upvoted 0 times
Tish
9 months ago
Choosing Option B would align with the requirement to prevent customers from decreasing the bill value.
upvoted 0 times
...
Leatha
10 months ago
I think Option C and D are not as suitable for maintaining the integrity of the bill variable.
upvoted 0 times
...
Shelton
10 months ago
Option A might not provide the necessary protection against customers tampering with the bill value.
upvoted 0 times
...
Ettie
10 months ago
I agree, Option B would ensure that the bill is always calculated correctly based on electricity usage.
upvoted 0 times
...
...
Beata
11 months ago
That's a good point, Ashlyn. Option C does offer better protection against tampering. I see your point now.
upvoted 0 times
...
Ashlyn
11 months ago
I disagree, I believe the answer is Option C because it provides a more secure way to prevent tampering with the bill variable.
upvoted 0 times
...
Beata
11 months ago
I think the answer is Option A because it seems like the most straightforward way to ensure the bill is always calculated correctly.
upvoted 0 times
...

Save Cancel