access-modifiers

How to use Java access modifier properly in library devlopment

I'm developing a library which the other programmer will import and use it for their purposes. I'm confused about the objective of Java access modifier. The problem is that I have classes below ClassA in package org.mylibrary ClassB in package org.mylibrary.internal ClassA needs to resolve ClassB so ClassB need to be public class. ...

Why should the String constructor be protected instead of private here?

I'm a bit stuck on this SCJP practice question, specifically line 5 (with the String constructor). I thought it should be private, but the solution is 'protected'. I think protected access would not satisfy the requirement that all Alpha instances have the String alpha set to A. If the constructor is protected, then any other class that'...

Internal vs. Private Access Modifiers

What is the difference between the internal and private access modifiers in C#? ...

What is the difference between Dim, Global, Public, and Private as Modular Field Access Modifiers?

In VB6/VBA, you can declare module-level variables outside of a specific Sub or Function method. I've used Private and Public before inside modules and understand them like so: Public - visible to all code inside the module and all code outside the module, essentially making it global. Private - visible only to code inside the module....

Have you ever seen design with reasonable usage of protected internal access modifier?

I haven't, but I don't say there isn't one. All of the C# developers who read this probably do know what is protected internal and when to use it. My question is simple : did you actually ever use it or worked on a successfully designed project using protected internal access modifier? If yes, please share your knowledge and post nice s...

How can i hide "setters" from all but one assembly?

Hi Guys, I have alluded to this issue in my other question, but i think it's worthwhile breaking it out into its own question, as it's not really dependant on the other scenarios i mentioned. Anyways - onto the Q, don't know if this is possible. Looking for a solution/workaround. I have a Class Library, with nothing but POCO's: MyCom...

Why can't I access package-private fields in the android.widget package?

I'm attempting to override an Android View class to tweak the functionality just slightly. But I need to modify a field that does not have a setter method. I've placed the subclass in a package called android.widget. Why can't I access any of the package-private member fields? I notice that the compiler says they "cannot be resolved,...

Is there any use for a private constant, that is not static?

Is there any reason to have a private constant, that is not static? Are there any situations that you would need a non-static private const? Would it make sense if constants where static by default? I use ActionScript3 and some Java, but I think this is a broader OOP question. ...

How to change the access modifier of a user control

I have a user control created in xaml, lets name it "View". In the View.xaml.cs I changed the access modifier for the class View to internal: internal partial class View : ViewBase { ... } After changing the access modifier the compiler states the error: Partial declarations of 'A.B.View' have conflicting accessibility modifier...

C# explicit declare member interface

How to declare explicit a member of a interface?.i.e: public interface IPerfil { int IDPerfil { get; set; } int IDMarca { get; set; } int IDRegional { get; set; } int IDFilial ...