About Question com.enthuware.ets.scjp.v6.2.479 :

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

Moderator: admin

Post Reply
TwistedLizard
Posts: 57
Joined: Sat Mar 01, 2014 1:48 pm
Contact:

About Question com.enthuware.ets.scjp.v6.2.479 :

Post by TwistedLizard »

What classes can a non-static nested class extend ?
(Provided that the class to be extended is visible and is not final.)

Given answer is
3: Any Class

Shouldn't option
2: 'Any top level class.'
also be correct?

It's a subset of option 3 and also therefore correct.

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

Re: About Question com.enthuware.ets.scjp.v6.2.479 :

Post by admin »

No, "Any class" is the best option because of the reason you mentioned.
If you like our products and services, please help us by posting your review here.

TwistedLizard
Posts: 57
Joined: Sat Mar 01, 2014 1:48 pm
Contact:

Re: About Question com.enthuware.ets.scjp.v6.2.479 :

Post by TwistedLizard »

ok, thanks.

I thought I remembered answers here where the the logic was that both answers should be included. Maybe that memory is mistaken.

I think that in the actual test, the number of required answers is given.

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

Re: About Question com.enthuware.ets.scjp.v6.2.479 :

Post by admin »

Yes, that depends on how many answers you have to select. If only one then the best answer wins :)
If you like our products and services, please help us by posting your review here.

marcioggs
Posts: 10
Joined: Sat Aug 31, 2019 3:19 am
Contact:

Re: About Question com.enthuware.ets.scjp.v6.2.479 :

Post by marcioggs »

Shouldn't the correct answer be "None of the above" since it can't extend a final class?

Code: Select all

public class Outer {

    final class FinalClass {

    }

    // Compiler error: Cannot inherit from final 'Outer.FinalClass'
    class NonStaticNested extends FinalClass {

    }
}

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

Re: About Question com.enthuware.ets.scjp.v6.2.479 :

Post by admin »

Yes, that's why the last line of the problem statement says: (Provided that the class to be extended is visible and is not final.)
If you like our products and services, please help us by posting your review here.

sohamdatey22
Posts: 28
Joined: Sun Sep 11, 2022 3:55 am
Contact:

Re: About Question com.enthuware.ets.scjp.v6.2.479 :

Post by sohamdatey22 »

Can a call extend itself? if not, then Any class cannot be the correct answer.
It will cause, cycle detected compilation error, thus.
Any class except itself, otherwise none of the above.

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

Re: About Question com.enthuware.ets.scjp.v6.2.479 :

Post by admin »

You are logically correct but the usage of extend itself is applicable to a class other than itself. A class cannot use extends keyword on itself, in any situation, right? So that part has nothing to do with nested classes. In other words, "extends" implicitly implies a class other than itself. The problem statement therefore is clearly trying to explore if there are more restrictions on a nested class.
If you like our products and services, please help us by posting your review here.

Post Reply

Who is online

Users browsing this forum: No registered users and 68 guests