Is the purpose of an interface to hide information?

Total Post:88

Points:616

OOPS 
 1908  View(s)
Ratings:
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?

  1. Re: Is the purpose of an interface to hide information?

    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();

      Modified On Mar-30-2018 02:16:17 AM

Answer

Please check, If you want to make this post sponsored

You are not a Sponsored Member. Click Here to Subscribe the Membership.