Start networking and exchanging professional insights

Register now or log in to join your professional community.

Follow

Can we access the private method from outside the class?

user-image
Question added by Mohd shahnawaz khan , Associate Project , Cognizant Technology Solution
Date Posted: 2014/04/16
Abdullah Abdurrahman
by Abdullah Abdurrahman , Software Development Manager , Global Computer Services

According to object oriented rules, NO.

Prasanna Kumar S R
by Prasanna Kumar S R , Cyber Security Manager , MetLife

No not possible. Private modifiers are meant to be accessed only within that class.

yahia dekar
by yahia dekar , ingenieur d'etat en informatique , universite djilali liabbes - sidi bel abbes

no here we talks about a levet of security

about your question no

Mufeed Farhan
by Mufeed Farhan , HR Applications Manager , SBM

 

use setAccessible(true) on your Method object before using its invoke method for Java

and for C# and .net your can use the concept of friend or  System.Reflection class with InvokeMember .

 

This is good example on Java :

http://stackoverflow.com/questions//how-to-call-a-private-method-from-outside-a-java-class

 

I hope this info. is helpful to you .

  

More Questions Like This