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)?
About Question enthuware.ocajp.i.v7.2.1166 :
Moderator: admin
-
- Posts: 33
- Joined: Wed Nov 13, 2013 4:11 pm
- Contact:
-
- Posts: 33
- Joined: Wed Nov 13, 2013 4:11 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1166 :
that line should be
"What does the explanation "Only member variable can be volatile or transient." with the correct answer (3) mean?"
"What does the explanation "Only member variable can be volatile or transient." with the correct answer (3) mean?"
-
- Site Admin
- Posts: 10068
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1166 :
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.
HTH,
Paul.
If you like our products and services, please help us by posting your review here.
Who is online
Users browsing this forum: Google [Bot] and 142 guests