Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Are these correct forms of inner class??

 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are following correct forms of inner class:
A. private final abstract class in
B. new innerclass() implements someinterface
 
Marcela Blei
Ranch Hand
Posts: 477
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
NO.
>A. private final abstract class in
You can�t use abstract and final modifiers at the same time. Think about the concept of each one. But you may use the private modifier for an inner class and you can declare an inner class to be abstract or final.
>B. new innerclass() implements someinterface
This one is supose to be an anonymous inner class? When you declare this kind on inner classes you can�t use the extends or implements keywords and you have to implement the class.
eg.

where the: new SomeInterface() {
(look at the open braces) means: implements SomeInterface with the following code.
I don�t know if that was clear, try reading a bit about anonymous inner classes.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic