Page 1 of 1

About Question enthuware.ocajp.i.v7.2.1166 :

Posted: Mon Nov 25, 2013 5:55 pm
by javaman
Which line of code will not be acceptable to the compiler?

public class XBox{
volatile int root = 20; //1
private XBox() //2
{
volatile int i = 30; //3
}
private void XBox() //4
{
int local = 30;
}
}

What does the explanation "Only member variable can be volatile or transient." with the correct answer (3)?

Re: About Question enthuware.ocajp.i.v7.2.1166 :

Posted: Mon Nov 25, 2013 6:11 pm
by javaman
that line should be
"What does the explanation "Only member variable can be volatile or transient." with the correct answer (3) mean?"

Re: About Question enthuware.ocajp.i.v7.2.1166 :

Posted: Mon Nov 25, 2013 6:18 pm
by admin
It means you can apply volatile or transient only to a member variable i.e. instance or static. Not to a local variable.

HTH,
Paul.