Oracle
1Z0-851 · Question #75
1Z0-851 Question #75: Real Exam Question with Answer & Explanation
Sign in or unlock 1Z0-851 to reveal the answer and full explanation for question #75. The question stem and answer options stay visible for context.
Question
Given: 1. public class Target { 2. private int i = 0; 3. public int addOne() { 4. return ++i; 5. } 6. } And: 1. public class Client { 2. public static void main(String[] args){ 3. System.out.println(new Target().addOne()); 4. } 5. } Which change can you make to Target without affecting Client?
Options
- ALine 4 of class Target can be changed to return i++;
- BLine 2 of class Target can be changed to private int i = 1;
- CLine 3 of class Target can be changed to private int addOne(){
- DLine 2 of class Target can be changed to private Integer i = 0;
Unlock 1Z0-851 to see the answer
You've previewed enough free 1Z0-851 questions. Unlock 1Z0-851 for full answers, explanations, the timed quiz mode, progress tracking, and the master PDF. Question stem and options stay visible so you can still see what's on the exam.