• 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

Inheritance Completion Problem

 
Ranch Hand
Posts: 384
MyEclipse IDE Spring Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 15510
363
  • Likes 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Stephen.
 
naveen yadav
Ranch Hand
Posts: 384
MyEclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
reply
    Bookmark Topic Watch Topic
  • New Topic