• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Abstract class constructor

 
Ranch Hand
Posts: 1051
Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As we all know that constructor have to deal with the object instantiation.....

then how can a Astract class have a constuctor....

Just look into a PageNo-131 of kathy book......
first line of Topic constructor basics says......
"Every class, including abstract classes, MUST have a constructor. Burn that into your
brain. But just because a class must have one, doesn't mean the programmer has to
type it."

but how please clarify.....
 
Ranch Hand
Posts: 173
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Shanky,

Please remember that the constructor is a access point where in you can define the initial state
of your newly created instance.

Since the state of the instance is also governed by what it inherits, it is necessary to invoke that parent class constructor.

Remember you can never do


But this constructor will be called when any subclass is created during the object creation.

All the parts are nicely explained further in the book. Have a go at the later part & come back if you have more queries.

Remember - the asbtract class constructor helps in creating the subclass instance & initialize the inherited part of the subclass instance
This does not mean that a abstract class instance is being created when the constructor is invoked through subclass instance
creation chain.
 
Shanky Sohar
Ranch Hand
Posts: 1051
Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks now i understand that.........
 
Avishkar Nikale
Ranch Hand
Posts: 173
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You are welcome Shanky,

Please do not hesitate to ask questions. Questions like these keep on re-inforcing your fundamentals.

Also you can navigate & search the forum if these type of questions have been asked previously.

This forum is an excellent sand-box where we can bruise ourselves as much as we want
before we head out for the test.


 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic