Home > DeveloperSection > Forums > Is the purpose of an interface to hide information?
jacob rasel
jacob rasel

Total Post:88

Points:616
Posted on    June-12-2013 5:24 AM

 OOPS OOPS 
Ratings:


 1 Reply(s)
 1108  View(s)
Rate this:

Given that interfaces are also used to help hide information, giving the user only a subset of the possible methods they are allowed to use, and, let's say, I have a Person class and interface IPerson.

Now in main, I'm allowed to do

IPerson testy = new Person();

or

Person testy = new Person();

So really I'm not restricted from using Person still. So how does the interface truly hide data?



Vijay Shukla

Total Post:100

Points:700
Posted on    June-12-2013 7:53 AM

Hey Jacob Rasel!

What if You dont have that Person class.

 Object obj = loadObject();

 

 if(obj is IPerson) {

 

  IPerson person = (IPerson) obj;

 

 }

or

  IPerson person = loadPerson();


Don't want to miss updates? Please click the below button!

Follow MindStick