exam questions

Exam 1z0-809 All Questions

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

Exam 1z0-809 topic 1 question 55 discussion

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

Given:
public class Customer {
private String fName;
private String lName;
private static int count;
public customer (String first, String last) {fName = first, lName = last;
++count;}
static { count = 0; }
public static int getCount() {return count; }
}
public class App {
public static void main (String [] args) {
Customer c1 = new Customer("Larry", "Smith");
Customer c2 = new Customer("Pedro", "Gonzales");
Customer c3 = new Customer("Penny", "Jones");
Customer c4 = new Customer("Lars", "Svenson");
c4 = null;
c3 = c2;
System.out.println (Customer.getCount());
}
}
What is the result?

  • A. 0
  • B. 2
  • C. 3
  • D. 4
  • E. 5
Show Suggested Answer Hide Answer
Suggested Answer: D 🗳️

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
thetech
Highly Voted 4 years, 8 months ago
Answer is D=4. Tested
upvoted 8 times
...
asdfjhfgjuaDCV
Most Recent 4 months, 3 weeks ago
Tested: 4 is the correct answer
upvoted 1 times
...
steefaand
5 months, 3 weeks ago
Selected Answer: D
D is correct as count is increased only when new object is created. Since it is static variable it is shared among all instances.
upvoted 1 times
...
GaelBernard
11 months, 3 weeks ago
Selected Answer: D
Each call to constructor increases count by 1. count starts at 0 and there are 4 calls to constructor. It makes count = 4 at the end when printing.
upvoted 1 times
...
WilsonKKerll
2 years, 4 months ago
Answer is D.
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