answersLogoWhite

0

The method is only accessible to the class and friends of the class.

User Avatar

Wiki User

13y ago

What else can I help you with?

Related Questions

What kind of method is applied to all objects of a class rather than individual?

A class static method can be applied to all objects of a class.


Can a private method be overridden?

No. A method that is declared as private in a class is not inherited by any other class and hence if another class that extends this class declares a method with the same name and signature, it does not mean that this method is overridden. It is an entirely separate entity.


What is meant by private visibilty of a method?

It means that the method is visible from only within the current method. Also, any class that wants to use or invoke the private method has to create an object of the class in which the method is created in order to access/invoke it. The private access modifier is the most restrictive of the four java access modifiers. The total opposite of private is public which gives access to everyone.


Does java class must have public method?

no you can have a class with no public methods and even with a a private constructor public class Example { //constructor private Example(){ } }


What does private mean in java?

Members marked private can't be accessed by code in any class other than the class in which the private member was declared. Let's make a small change to the Parent class from an earlier example. package pack1; public class Parent { private String getName() { return "Parent"; } } Now the getName() method is private and is not visible from within the Child class and the same piece of code would throw up the below compilation error when you try to compile the class. cannot find symbol symbol : method getName() This error method looks as if the method getName() does not exist at all. Of course the method exists but unfortunately it is declared private and hence no class (except the class that has the exact code written into it) can access it. This includes a child class that extends the parent class that has the method.


What will happen if a Java Class has no Main Method?

Nothing will happen. There is no restriction that every Java class must have a main method. The only program is that, this class cannot be executed as a standalone java program.


What is a private class?

A private class is a class that cannot be directly accesed from outside its outer class, similar to a private variable or method. This means that a private class must always be an inner class, though an inner class can be public or protected instead. For instance, the following is valid and means that any X object cannot directly access the inner Y class. public class X { private class Y{} } The following however is invalid. private class X{}


Any method in a super class can be overridden in its subclass?

False.Any method declared as final cannot be overridden by any subclasses.You also cannot technically override a private method. While your subclass can have a method with the same definition as a private method in the superclass, it does not actually override that method.


What is the major difference between public and private access method in computer programming?

public means this can be accessed from any class private means this can be accessed only from the current class


Can you declared constructor as private?

If you declare the main method anything other than public, it will not run. If you declare main method as private, you would not be able to execute the class as a standalone java program. Any java class that needs to be executed as a standalone file needs to have a main method that is public, static and returns a void. Otherwise the Java compiler would not recognize the file as an executable standalone java file and would not allow you to run it.


How do you access a base class method from a derived class in Cpp?

Use the scope resolution operator (::) to explicitly call the base class method. Note that the base class method must be protected or public in order for a derived class to access it. Private members are only accessible to the class itself and to friends of the class, regardless of whether the derivative uses public, protected or private inheritance. It is quite normal for a base class to provide a "default" implementation for a virtual method for which a derived class may override. Although the derived class will generally provide its own implementation of the method, it may also call the base class method either before, during or after performing its own implementation. The following shows minimal class declarations demonstrating a call to a protected base class method from a derived class override. class base { protected: // accessible to all instances of this class, its friends and its derivatives. virtual void method(){ /* do something */ } }; class derived : public base { public: // full-accessible outside of class. virtual void method(){ /* do something (or do nothing) */ base::method(); // call base class method. /* do something else (or do nothing) */ } };


What does private int mean in java?

The private keyword denotes that the field or method is hidden from view of any other class. class MyClass { private int n; // n cannot be accessed by any class except MyClass private void doSomething(){} // doSomething cannot be accessed by any class except MyClass }