Java Programming - Inner Classes - Discussion

Discussion Forum : Inner Classes - General Questions (Q.No. 3)
3.
Which is true about a method-local inner class?
It must be marked final.
It can be marked abstract.
It can be marked public.
It can be marked static.
Answer: Option
Explanation:

Option B is correct because a method-local inner class can be abstract, although it means a subclass of the inner class must be created if the abstract class is to be used (so an abstract method-local inner class is probably not useful).

Option A is incorrect because a method-local inner class does not have to be declared final (although it is legal to do so).

C and D are incorrect because a method-local inner class cannot be made public (remember-you cannot mark any local variables as public), or static.

Discussion:
15 comments Page 2 of 2.

Karishma said:   1 decade ago
Why method is not static?

Moin khan said:   1 decade ago
Why inner class cannot be made static?

Smartgoat said:   1 decade ago
Why a method-local inner class does not have to be declared final?

Shreeja said:   1 decade ago
Because it is only visible to the enclosing class so no use making it public.

Niks said:   1 decade ago
Why inner class can't be made public ?


Post your comments here:

Your comments will be displayed after verification.