• Post Reply Bookmark Topic Watch Topic
  • New Topic

Core Java  RSS feed

 
Sailendra Jena
Greenhorn
Posts: 10
Hibernate Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why static initialization block, instance initialization block & constructor of a class can't be override in the subclass?
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sailendra Jena wrote:Why static initialization block, instance initialization block & constructor of a class can't be override in the subclass?

static initialization block can not be override because it is not bounded to an object i.e, it is a static-which executes while class is loading into jvm.
instance initialization block- the code inside this block is copied into constructor by java compiler . so now constructor can not be override because it is implicitly static . the overriding comes to the picture when only object fully constructed!
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
and Please, UseAMeaningfulSubjectLine
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!