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

Help and support on OCA OCP Java Programmer Certification Questions
1Z0-808, 1Z0-809, 1Z0-815, 1Z0-816, 1Z0-817

Moderator: admin

Post Reply
admin
Site Admin
Posts: 10053
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

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

Post by admin »

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.
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.
If you like our products and services, please help us by posting your review here.

OlgaAG
Posts: 10
Joined: Thu Jan 03, 2019 3:08 pm
Contact:

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

Post by OlgaAG »

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);

}
}

admin
Site Admin
Posts: 10053
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

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

Post by admin »

What did it print?
If you like our products and services, please help us by posting your review here.

OlgaAG
Posts: 10
Joined: Thu Jan 03, 2019 3:08 pm
Contact:

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

Post by OlgaAG »

nothing without errors

admin
Site Admin
Posts: 10053
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

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

Post by admin »

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?
If you like our products and services, please help us by posting your review here.

OlgaAG
Posts: 10
Joined: Thu Jan 03, 2019 3:08 pm
Contact:

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

Post by OlgaAG »

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;
        }

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 30 guests