static variable is class level variable and it is shared to all objects of that class. and whenever its value gets updated it will update to all objects. so correct ans is 5 4 5 6
X x1 = new X();
X x2 = new X();
x1.i = 3; // i is static (class variable), i = 3
x1.j = 4; // j is an instance variable, so for x1, j is 4
x2.i = 5; // i is updated from 3 to 5;
x2.j = 6; // j is an instance variable, so for x2 j is 6
Option C is correct.
Reason is because variable i is declared static so when;
x2.i = 5
is called, all X objects i values contain the new assigned value.
The correct answer is C
public class X {
static int i;
int j;
public static void main(String[] args) {
X x1 = new X();
X x2 = new X();
x1.i = 3;
x1.j = 4;
x2.i = 5;
x2.j = 6;
System.out.println(x1.i + " " + x1.j + " " + x2.i + " " + x2.j);
}
}
upvoted 3 times
...
This section is not available anymore. Please use the main Exam Page.1z0-808 Exam Questions
Log in to ExamTopics
Sign in:
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.
dya45792
Highly Voted 5 years, 3 months agov323rs
Highly Voted 5 years, 2 months agodin_sub077
Most Recent 4 weeks, 1 day agovic88
4 months, 1 week agoAhmadTechie
1 year, 4 months agoDolly2901
1 year, 8 months agoVicky_65
2 years agoanmoldev2java
2 years, 4 months agoRoxyFoxy
2 years, 7 months agoAndrei_Nicolae
2 years, 9 months agohexadecimal82
2 years, 9 months agohexadecimal82
2 years, 9 months agoSSJ5
4 years agoStewart125
4 years, 6 months agoSamAru
4 years, 9 months agomete23
5 years, 2 months ago