Page 1 of 1

About Question enthuware.ocpjp.v8.2.1311 :

Posted: Tue Mar 19, 2019 11:37 am
by crazymind

Code: Select all

Non-static nested classes, unlike normal package classes, can have any type of accessibility. 
But in Jeanne Boyarsky, Scott Selikoff' book says this regarding Local inner class:
They do not have an access specifier.
They cannot be declared static and cannot declare static fields or methods.
I am not quite sure which one is correct. The non-static inner class can have constant members but no static methods are allowed, right? What about access modifier? thank you!

Re: About Question enthuware.ocpjp.v8.2.1311 :

Posted: Tue Mar 19, 2019 8:01 pm
by admin
Observe the statements carefully. First one says non static nested classes and second one says local inner classes. Both are correct.

Re: About Question enthuware.ocpjp.v8.2.1311 :

Posted: Tue Mar 19, 2019 11:15 pm
by crazymind
admin wrote:
Tue Mar 19, 2019 8:01 pm
Observe the statements carefully. First one says non static nested classes and second one says local inner classes. Both are correct.
Non-static nested classes, unlike normal package classes, can have any type of accessibility.
But in Jeanne Boyarsky, Scott Selikoff' book says this regarding Local inner class:
They do not have an access specifier.
They cannot be declared static and cannot declare static fields or methods.
Are these two conflict each other regarding the access modifier? Thanks

Re: About Question enthuware.ocpjp.v8.2.1311 :

Posted: Tue Mar 19, 2019 11:24 pm
by admin
Non static nested class:
class Outer{
public|private|protected class Inner{ <<---- Any access modifier
}
}

Local Inner Class :
someMethod(){

class LocalInnerClass { <<--- can't have any access modifer

}

}

Re: About Question enthuware.ocpjp.v8.2.1311 :

Posted: Tue Mar 19, 2019 11:31 pm
by crazymind
admin wrote:
Tue Mar 19, 2019 11:24 pm
Non static nested class:
class Outer{
public|private|protected class Inner{ <<---- Any access modifier
}
}

Local Inner Class :
someMethod(){

class LocalInnerClass { <<--- can't have any access modifer

}

}
Thanks, that's what I thought in the first place. I am confused since the solution says non-static classes can have any access modifier but it should exclude local inner class.

Re: About Question enthuware.ocpjp.v8.2.1311 :

Posted: Tue Mar 19, 2019 11:39 pm
by admin
Sure, enhanced the statement to avoid the confusion.
thank you for your feedback!