• 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

protected access for constructors.

 
Ranch Hand
Posts: 153
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Could any one explain different accessability modifier for constructors.

Throw more light on protected access.
 
Ranch Hand
Posts: 139
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hello Girish,

A constructor can have any of the modifier that is permitted by JLS. i.e it can be private , public , protected or default.

the choice which one to use is all yours and your requriment of course.
 
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
constructor can have any access specifiers.. as the person abv me said.. and comming to private u need a public static method for that class so that u can get into that class and then call the constructor. this is wat private deals with..

and i have not come accross any spl use of declaring any constructor as protected.. if it is a normal method which is protected then it is ok... i am not sure of protected constructor...
 
Ranch Hand
Posts: 2023
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Protected members--methods, variables, constructors, and inner classes--are available to all classes in the same package as the declaring class (whether subclass or not) and to all subclasses of the declaring class (whether same package or not).
reply
    Bookmark Topic Watch Topic
  • New Topic