By default a method is a private or public or protected? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

By default a method is a private or public or protected?

11th Sep 2016, 5:08 PM
Dheeraj Reddy
Dheeraj Reddy - avatar
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.
11th Sep 2016, 5:39 PM
Tiger
Tiger - avatar
+ 2
by default the method is of type "default" which means "public to the package"
22nd Sep 2016, 7:42 AM
Rajesh
Rajesh - avatar
0
no modifier mans it's friendly
11th Sep 2016, 6:29 PM
Nitesh Waghmare
0
by default it is package limit
13th Sep 2016, 5:16 PM
Teja Naraharisetti
Teja Naraharisetti - avatar
- 1
by default it's public
5th Oct 2016, 3:58 PM
Ameya
Ameya - avatar
- 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 } }
7th Oct 2016, 4:07 AM
Vishwanath Patil
Vishwanath Patil - avatar
- 1
public by default
20th Oct 2016, 7:41 AM
Nagashree BS
Nagashree BS - avatar