0
By default a method is a private or public or protected?
7 Answers
+ 2
If there is no modifier then it is a package private. So the access level of the method will be within its class and its subclasses in the same package and within its package.l level.
However it is Not visible in other packages and other subclasses lives in other packages.
+ 2
by default the method is of type "default"
which means "public to the package"
0
no modifier mans it's friendly
0
by default it is package limit
- 1
by default it's public
- 1
private.
e.g:-
class Base
{
int id;
public void pdata()
{
}
}
class Derived:Base
{
public Derived()
{
id=5; //error id is a private member of a Base class
}
}
- 1
public by default