class test07{
public static int stvar = 100;
public int var = 200;
public String toString(){
return stvar + ":" + var;
}
public static void main(String[] args) {
test07 t1 = new test07();
t1.var= 300;
System.out.println(t1);
test07 t2 = new test07();
t2.stvar =300;
System.out.println(t2);
}
}
The answer is the letter D. Even though stVar is static, but it was printed before receiving the new value, so in line 3 it still had the value of 100.
upvoted 4 times
...
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.
sina_
6 months, 1 week agoiSnover
1 year, 3 months ago