Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

can a contructor be declared protected...  RSS feed

 
Raju Champaklal
Ranch Hand
Posts: 521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the code compiles....but what is the use of a protected contructor when they are never inherited?
 
Ankit Garg
Sheriff
Posts: 9608
36
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I see correctly, the heading says "can a contructor be declared postive? " . A protected constructor allows the class to be inherited but cannot be instantiated outside of the package. So if a class com.mypackage.MyClass has protected constructor(s), then the MyClass can be inherited but cannot be instantiated outside of com.mypackage package...
 
Raju Champaklal
Ranch Hand
Posts: 521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks Ankit

Raju
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!