AF
HomeTagSubmit NotesAsk AnythingLoginSubscribe Us
AF
1. Feel Free to ask and submit anything on Anyforum.in and get satisfactory answer
2. Registration is not compulsory, you can directly login via google or facebook
3. Our Experts are looking for yours ?.



OOPs-inheritance: How to access private method of super class in sub class?

Can we access the private method of a parent class in child class? If yes then please tell me how?

OOPs x 49
inheritance x 7
Posted On : 2014-04-25 19:20:09.0
profile Saksham Kumar - anyforum.in Saksham Kumar
73433936114
up-rate
5
down-rate

Answers


Yes, you can call private method in another class even you don´t need to extend it. You can do it by reflection API. Following link describes very well explained example of calling private method in another class.
Example of Calling Private Method in another class

We declare the method as private due to some reason. and private method can not be called in child class normally as we call default or public methods. If you want to restrict any method to be accessed in another class, You can use protected in place of private.

Posted On : 2014-04-25 20:06:09
Satisfied : 1 Yes  0 No
profile Garima Gupta - anyforum.in Garima Gupta
596129554554
Reply This Thread
up-rate
5
down-rate



Post Answer
Please Login First to Post Answer: Login login with facebook - anyforum.in