exam questions

Exam 1z0-808 All Questions

View all questions & answers for the 1z0-808 exam

Exam 1z0-808 topic 1 question 17 discussion

Actual exam question from Oracle's 1z0-808
Question #: 17
Topic #: 1
[All 1z0-808 Questions]

Given this class:

And given this main method, located in another class:

Which three lines, when inserted independently at line n1, cause the program to print a 0 balance? (Choose three.)

  • A. acct.setAmount(-acct.getAmount());
  • B. acct.amount = 0;
  • C. acct.setAmount(0);
  • D. acct.getAmount() = 0;
  • E. this.amount = 0;
  • F. acct.changeAmount(0);
  • G. acct.changeAmount(-acct.amount);
Show Suggested Answer Hide Answer
Suggested Answer: BCG 🗳️

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
baledevit
Highly Voted 2 years, 3 months ago
Selected Answer: BCG
The correct answer is BCG B - The variable "amount" in Class CheckingAccount is public, which allows the change from the instance to the main method C - method setAmount () when called from the instance in the main method allows to modify the variable "amount" in the instance of CheckingAccount G - The changeAmount () method receives in input the same value present in the CheckingAccount instance but in negative. Being public, the variable does not generate an error.
upvoted 6 times
...
MPignaProTech
Most Recent 2 months, 1 week ago
Selected Answer: BCG
BCG is the correct answer
upvoted 1 times
...
fvelazqueznava
1 year, 3 months ago
Selected Answer: BCG
BCG are the correct
upvoted 4 times
...
DarGrin
1 year, 3 months ago
Selected Answer: BCG
BCG are correct answers
upvoted 2 times
...
DarGrin
1 year, 3 months ago
BCG are correct answers
upvoted 2 times
...
somrita90
1 year, 4 months ago
BCG are the answer, You guys given D which is compilation error, acct.getAmount() = 0; not possible in java.
upvoted 1 times
...
dsms
1 year, 5 months ago
Selected Answer: BCG
B C G - tested!
upvoted 1 times
...
tuyetan
1 year, 7 months ago
B C G
upvoted 2 times
...
dastkoz
1 year, 8 months ago
Selected Answer: BCG
tested locally.
upvoted 2 times
...
spongecodes
1 year, 10 months ago
Selected Answer: BCG
BCG is the correct answer
upvoted 3 times
...
Ankit1010
1 year, 11 months ago
B, C, G are the correct answer.
upvoted 3 times
...
RAADEL3IMLAK
2 years ago
the good answer is just B and C
upvoted 1 times
...
anmoldev2java
2 years, 1 month ago
Selected Answer: BCG
this is crorrect
upvoted 2 times
...
carloswork
2 years, 2 months ago
Selected Answer: BCG
Tested, answer is BCG.
upvoted 2 times
carloswork
2 years, 2 months ago
import java.lang.Math; public class CheckingAccount { public int amount; public CheckingAccount (int amount) { this.amount = amount; } public int getAmount() { return amount; } public void setAmount(int amount) { this.amount = amount; } public void changeAmount(int x) { amount += x; } public static void main(String[] args) { CheckingAccount acct = new CheckingAccount((int)(Math.random()*1000)); acct.amount = 0; /* B */ System.out.println(acct.getAmount()); acct.setAmount(0); /* C */ System.out.println(acct.getAmount()); acct.changeAmount(-acct.amount); /* G */ System.out.println(acct.getAmount()); } }
upvoted 2 times
...
...
wk8b
2 years, 3 months ago
Selected Answer: BCG
correct answer BCG
upvoted 1 times
...
Philip0908
2 years, 4 months ago
Selected Answer: BCG
The answer is BCG
upvoted 4 times
shivkumarx
2 years, 3 months ago
Tested and agreed
upvoted 1 times
...
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...
exam
Someone Bought Contributor Access for:
SY0-701
London, 1 minute ago