• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

Regarding inner classes

 
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I am preparing for the SCJP but i fount is interesing while i observed some scenarios. I am curious about these things and want to get my doubts cleared.Here are the some observations i could make out.

1. What is the sigmificance of a regular inner class which is abstract or an interface.
2. If i have a inner class which is abstract or an interface what is its significance outside the class, For ex:

public class Test {
public abstract class Inner{
}
}
class Test1 extends Test{
Test.Inner ob = new Test().new Inner();
}
Can i instantiate the inner class somehow in Test1.If yes what will be the syntax.
 
Ranch Hand
Posts: 621
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes i think you can instantiate inner class!!!
 
Ranch Hand
Posts: 424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Same rules apply as top level classes, you cannot instantiate abstract classes.
 
Ranch Hand
Posts: 1274
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, but you could make an anonymous class of the abstract class, e.g.
output is something like
Test$1@1f6a7b9

Then you have an anonymous inner class of an abstract inner class...

(I removed the public modifiers to have them all in one file)



Yours,
Bu.
 
rubbery bacon. crispy tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic