This option is marked as incorrect and rightly so because of the reason mentioned by you and also by the explanation. The option is actually quite clear.AndaRO wrote:Please reformulate the first option.
Currently:
private keyword can never be applied to a class.
Correct:
private keyword can never be applied to a top level class.
because you said:
private, protected and public can be applied to a nested class.
The first option is confusing.
About Question enthuware.ocajp.i.v7.2.1362 :
Moderator: admin
-
- Site Admin
- Posts: 10053
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1362 :
If you like our products and services, please help us by posting your review here.
-
- Posts: 10
- Joined: Thu Jan 03, 2019 3:08 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1362 :
Option "A final variable can be hidden in a subclass."
The explanation does consider the no-final variable. I tried to hide no-final variable in IDE. It printed nothing. Why it does not printed a subclass final variable ?
public class Test {
final int c = 10;
public static void main(String[] args) {
}
}
class Test1 extends Test {
final int c = 50;
public static void main(String[] args) {
Test1 f1 = new Test1();
System.out.println(f1.c);
}
}
The explanation does consider the no-final variable. I tried to hide no-final variable in IDE. It printed nothing. Why it does not printed a subclass final variable ?
public class Test {
final int c = 10;
public static void main(String[] args) {
}
}
class Test1 extends Test {
final int c = 50;
public static void main(String[] args) {
Test1 f1 = new Test1();
System.out.println(f1.c);
}
}
-
- Site Admin
- Posts: 10053
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1362 :
What did it print?
If you like our products and services, please help us by posting your review here.
-
- Posts: 10
- Joined: Thu Jan 03, 2019 3:08 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1362 :
nothing without errors
-
- Site Admin
- Posts: 10053
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1362 :
Well, then you are doing something wrong. The print statement should definitely print something, right? Unless you are trying to run Test instead of Test1.
Are you using the command line or an IDE?
Are you using the command line or an IDE?
If you like our products and services, please help us by posting your review here.
-
- Posts: 10
- Joined: Thu Jan 03, 2019 3:08 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.1362 :
I tried to run Test instead of Test1 by IDE. I fixed the code and everything turned out. Thank you!
Code: Select all
public class Test {
final int c = 10;
public static void main(String[] args) {
Test1 f1 = new Test1();
System.out.println(f1.c); } //Output 50
}
class Test1 extends Test {
final int c = 50;
}
Who is online
Users browsing this forum: Google [Bot] and 30 guests