What is the result?

Given the code fragment:

What is the result?
A. 5: 5
B. 10:10
C. 5: 10
D. Compilation fails

Download Printable PDF. VALID exam to help you PASS.

5 thoughts on “What is the result?

  1. Answer B:

    For a small, but significant reason: The “count” variable is static. Meaning that it is a “class-specific” variable, NOT an instance variable. Therefore, the value of “count” will be updated in the class Test each time ANY instance update its value. Accordingly, the updated value is shared among all the instance.
    This is not the case with the variable “i”. Since it does not have the “static” keyword, it means it is an instance variable. Meaning that its value is SPECIFIC to the instance. So if you try to print check1.i and check2.i you will get 5 and 5 consequently.

Leave a Reply

Your email address will not be published. Required fields are marked *

The reCAPTCHA verification period has expired. Please reload the page.