Accenture Primer
Accenture DumpmediumAccenture PrimerPrimer-Dump

Accenture Accenture Primer Practice Question

predict output class TestMain{ int x=50;

Answer options

A
public static void main (String[] args) {
B
final TestMain f1= new TestMain();
C
TestMain f2 = new TestMain();
D
TestMain f3 = isvalid(f1,f2);
E
System.out.println(f1==f3)+""+(f1.x==f3.x));
F
static TestMain isvalid(TestMain x,TestMain y){
G
final TestMain z=x;
H
x=60;
I
return z;
J
ans= true true

Correct answer: ans= true true

Explanation

f3 = isvalid(f1, f2): z = x (z points to f1), then the method returns z (which is f1). So f3 == f1 is true, and f1.x == f3.x is true (both point to same object, x=50). Output: true true.

Related Accenture Accenture Primer questions

Practice more Accenture Accenture Primer questions

PrimerDumps has 1400+ primer questions, 2026 mocks and coding hands-on — all free.