About Question com.enthuware.ets.scjp.v6.2.479 :
Moderator: admin
-
- Posts: 57
- Joined: Sat Mar 01, 2014 1:48 pm
- Contact:
About Question com.enthuware.ets.scjp.v6.2.479 :
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.
(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.
-
- Site Admin
- Posts: 10062
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question com.enthuware.ets.scjp.v6.2.479 :
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.
-
- Posts: 57
- Joined: Sat Mar 01, 2014 1:48 pm
- Contact:
Re: About Question com.enthuware.ets.scjp.v6.2.479 :
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.
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.
-
- Site Admin
- Posts: 10062
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question com.enthuware.ets.scjp.v6.2.479 :
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.
-
- Posts: 10
- Joined: Sat Aug 31, 2019 3:19 am
- Contact:
Re: About Question com.enthuware.ets.scjp.v6.2.479 :
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 {
}
}
-
- Site Admin
- Posts: 10062
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question com.enthuware.ets.scjp.v6.2.479 :
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.
-
- Posts: 28
- Joined: Sun Sep 11, 2022 3:55 am
- Contact:
Re: About Question com.enthuware.ets.scjp.v6.2.479 :
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.
It will cause, cycle detected compilation error, thus.
Any class except itself, otherwise none of the above.
-
- Site Admin
- Posts: 10062
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question com.enthuware.ets.scjp.v6.2.479 :
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.
Who is online
Users browsing this forum: pavvel and 114 guests