QuestionQ3

Java Object-Oriented Approach

Given the following code:

Question Image

What is the output?

  • A 1001001000
  • B 1011011000
  • C 10011001000
  • D 100110011000
Explanation

Java passes the int argument by value, so incrementing the method parameter changes it from 1000 to 1001 only within myMethod. The expression this.x refers to the instance field, which remains 100. The local variable in main also remains 1000, producing 10011001000.

Community Discussion

No comments yet. Be the first to start the discussion!