AF
HomeTagSubmit NotesAsk AnythingLoginSubscribe Us
AF
1. Feel Free to ask and submit anything on Anyforum.in and get satisfactory answer
2. Registration is not compulsory, you can directly login via google or facebook
3. Our Experts are looking for yours ?.



corejava-OOPs: Hiding concept in java?

How can we hiding the variables like local variables, instance variables, and static variables or class variables in java.


Could you please explain hiding concept in java.




Thanking you.

corejava x 336
OOPs x 49
Posted On : 2016-08-14 06:18:59.0
profile MOHAMMAD SALEEM BASHA - anyforum.in MOHAMMAD SALEEM BASHA
266150
up-rate
4
down-rate

Answers


Hiding concept is all about abstraction and encapsulation. Like if you want to hide the complexity and want to show the functionality just use abstract classes or interface. Like DriverManager.getConnection("Connection String") returns the Connection Interface reference. We just know only Connection interface but we don´t know how it´s making the connection with DB as per connection String, So we hide all functionality of implemented class by returning parent interface´s or abstract class´s reference. On other way data hiding is all about to limit the scope of your variables using access modifiers or the putting the data in a limited scope is called Encapsulation. we are making our variables private it means they are class protected.If we want our instance variables to be accessible throughout the package then they are package protected. Through out project they are public. So what I mean to say is to hide data you need some sort of container where you will put your data and hide with respect to container.

So Data Hiding is not possible without Encapsulation. You can´t hide your data without putting it in some form of container. Again I´m reminding you that I´m putting this on the Object Oriented Language context.

But yes Encapsulation is possible without hiding your data. We always place the things on its appropriate place like methods can be places in class or interface and all classes we can place in a package. whether we make its variables public, private or protected.

Posted On : 2016-08-14 15:51:02
Satisfied : 1 Yes  0 No
profile Garima Gupta - anyforum.in Garima Gupta
596128622692
Reply This Thread
up-rate
3
down-rate



Post Answer
Please Login First to Post Answer: Login login with facebook - anyforum.in