Professional Documents
Culture Documents
SCJP Test
SCJP Test
static
int x = 5;
x--; myMethod();
System.out.println(x + y + ++x);
y = x++ + ++x;
prints : 1
prints : 2
prints : 3
prints : 7
prints : 8
2. class Value
t.first();
int i = 5;
v.i = 25;
second(v, i);
System.out.println(v.i);
i = 0;
v.i = 20;
v = val;
}
a) 15 0
b) 20 0
c) 15 0
d) 20 20
3. What will happen when you attempt to compile and run the following code?
class MyParent
int x, y;
MyParent(int x, int y)
this.x = x;
this.y = y;
}
public int addMe(MyParent myPar)
int z;
super(x,y);
this.z = z;
{
return this.x + x + this.y + y + this.z + z;
int y = myChi.addMe(myChi);
int z = myPar.addMe(myPar);
System.out.println(x + y + z);
a) 300
b) 240
c) 120
d) 180
e) Compilation Error None of the above