Skip to content

Tag: private

Can a object be private and public?

Can a reference to an object be private in class while other object can have a public reference to the same class(post script: new to java+ a simple example please). I read somewhere that this prob is regarding aliasing? Sorry my title may not make sense! Answer Objects aren’t private or public. Fields …

What is the use of a private static variable in Java?

If a variable is declared as public static varName;, then I can access it from anywhere as ClassName.varName. I am also aware that static members are shared by all instances of a class and are not reallocated in each instance. Is declaring a variable as private static varName; any different from declaring a v…

groovy call private method in Java super class

I have an abstract Java class MyAbstractClass with a private method. There is a concrete implementation MyConcreteClass. In my groovy test class I have I get an error that there is no such method signature for somePrivateMethod. I know groovy can call private methods but I’m guessing the problem is that…