Communiquez avec les autres et partagez vos connaissances professionnelles

Inscrivez-vous ou connectez-vous pour rejoindre votre communauté professionnelle.

Suivre

Can we access the private method from outside the class?

user-image
Question ajoutée par Mohd shahnawaz khan , Associate Project , Cognizant Technology Solution
Date de publication: 2014/04/16
Abdullah Abdurrahman
par Abdullah Abdurrahman , Software Development Manager , Global Computer Services

According to object oriented rules, NO.

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

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

yahia dekar
par 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
par 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

Avez-vous besoin d'aide pour créer un CV ayant les mots-clés recherchés par les employeurs?