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, 7 months agov323rs
Highly Voted 5 years, 6 months agodin_sub077
Most Recent 4 months, 2 weeks agovic88
7 months, 3 weeks agoAhmadTechie
1 year, 8 months agoDolly2901
2 years agoVicky_65
2 years, 3 months agoanmoldev2java
2 years, 8 months agoRoxyFoxy
2 years, 10 months agoAndrei_Nicolae
3 years agohexadecimal82
3 years, 1 month agohexadecimal82
3 years, 1 month agoSSJ5
4 years, 4 months agoStewart125
4 years, 9 months agoSamAru
5 years agomete23
5 years, 5 months ago