The correct answer is B.
public static void main (String [] args) {
int x = 3, y = 5;
Test obj = new Test(x, y);
System.out.println(x + " " + y); // x = 3, y= 5;
System.out.println(obj.x + " " + obj.y); // x = 9, y= 25;
}
Answer is B.
To test:
public class Test {
int x, y;
public Test (int x, int y) {
initialize(x, y);
}
public void initialize (int x, int y) {
this.x = x * x;
this.y = y * y;
}
public static void main (String [] args) {
int x = 3, y = 5;
Test obj = new Test(x, y);
System.out.println(x + " " + y);
}
}
The right answer is the letter B, it prints the values of the variables x and Y on the last line, the test type object is just a distractor, be careful.
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.
v323rs
Highly Voted 4 years, 12 months agoHarid
Highly Voted 4 years, 4 months agoMPignaProTech
Most Recent 2 months, 4 weeks agoakbiyik
2 years, 1 month agocarloswork
2 years, 2 months agoiSnover
2 years, 3 months agoAyla
4 years, 2 months ago