Answer is A.
To test:
class Book {int pages;}
class App{
int count;
public void method (Book x, int k) {
x.pages = 100;
k = 200;
}
}
public class Test {
public static void main(String[] args) {
App obj = new App();
Book objBook = new Book();
System.out.println(objBook.pages + ":" + obj.count);
obj.method(objBook, obj.count);
System.out.println(objBook.pages + ":" + obj.count);
}
}
The answer is the letter A. In the first line where the printing occurs, notice that we did not instantiate the value of "objBook.pages" and "obj.count", as they are int, the default value of this type of variable is 0, so we have already eliminated answers B and D. even passing the "obj.count" in the "method" method, its value does not change because it is an instantiation variable in the App class and not its value remains 0 and it is in the second "println" in the second place, and the only answer that has "0:0" in the first line and "0" in the second place of the second line is the letter A.
upvoted 2 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.
carloswork
2 months, 2 weeks agoiSnover
3 months ago