• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

Inheritance Completion Problem

 
Ranch Hand
Posts: 384
MyEclipse IDE Spring Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Look at code :





The rule is super class constructor must run implictly or explictly.

In line 3 , super class CRT constructor is called explictly.
and as a result construcor in line 1 calls the super() of Object class.So hiearrchy is complete.

Then Why is ERROR in line 2. ???



 
Saloon Keeper
Posts: 10307
217
  • Likes 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Implicit constructor calls will only try to call the no-arg constructor of the super-class. CRT doesn't have a no-arg constructor.

Note that your example abuses class hierarchies. LCD does not extend CRT. It may be a simple example class, but then make the hierarchies intuitive, like Dog extends Animal.
 
naveen yadav
Ranch Hand
Posts: 384
MyEclipse IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Stephen.
 
naveen yadav
Ranch Hand
Posts: 384
MyEclipse IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
it means compiler tries to insert super() call in line 2 and when it does not find no-arg constructor in CRT it slap with the error , right
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!