IS THE PURPOSE OF AN INTERFACE TO HIDE INFORMATION?

Total Post:88

Points:616
OOPS 
 1674  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. Post:100

    Points:700
    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

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!