Win a copy of Escape Velocity: Better Metrics for Agile Teams this week in the Agile and Other Processes forum!
  • 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
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

Regd Constructor

 
Ranch Hand
Posts: 145
Oracle Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ranchers,

Why constructor cannot be declared final?

Regards,
Nancy

 
Sheriff
Posts: 67671
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please use real words when posting to the forums. Abbreviations such as "regd" only serve to make your posts more difficult to read and less likely to generate useful responses.

Please read this for more information.

thanks,
bear
JavaRanch sheriff
 
Bartender
Posts: 6663
5
MyEclipse IDE Firefox Browser Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Nancy Antony wrote:Hi Ranchers,

Why constructor cannot be declared final?

Regards,
Nancy



Think about the possible uses of making a constructor final. Can you actually extend a constructor. Does it make sense to even say, a constructor is final ?
 
Ranch Hand
Posts: 215
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It wouldn't serve any purpose nor would it be useful in any way! It literally makes it unusable.

Regards,
John Eipe
 
Nancy Antony
Ranch Hand
Posts: 145
Oracle Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I understand that. But my doubt is like every method declared in interface is final. But still I can write final keyword when declaring a method in an interface. Likewise I felt may be constructor is declared as final implicitely. So when I declare it as final, why compile time error?

Regards,
Nancy
 
Ranch Hand
Posts: 537
Eclipse IDE Python Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

understand that. But my doubt is like every method declared in interface is final. But still I can write final keyword when declaring a method in an interface.



methods in an interface are never final and you cannot declare them as final because they are implicitly abstract and abstract and final are never legal. Also constructors can only be declared with access modifiers only that is (public, private and protected)
 
We should throw him a surprise party. It will cheer him up. We can use this tiny ad:
Garden Master Course kickstarter
https://coderanch.com/t/754577/Garden-Master-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic