aspose file tools*
The moose likes Beginning Java and the fly likes core java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "core java" Watch "core java" New topic
Author

core java

Hari Prasad M
Greenhorn

Joined: Feb 27, 2006
Posts: 3
what is encapsulation ? real time example ?

where we use reflection ? which situation ?


Hari Prasad Mallidi
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Check the index of any core Java book.


"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
ak pillai
author
Ranch Hand

Joined: Feb 11, 2006
Posts: 288
what is encapsulation ? real time example ?




Being able to encapsulate members of a class is important for security and integrity. We can protect variables from unacceptable values. The sample code below describes how encapsulation can be used to protect the MyMarks object from having negative values. Any modification to member variable �vmarks� can only be carried out through the setter method setMarks(int mark). This prevents the object �MyMarks� from having any negative values by throwing an exception.



Reflection is used when you have to introspect a class and its memebers to do stuff dynamically. This is used by lot of application frameworks like Hibernate etc, java based editors, etc. Code with intrspection can adversely affect performance proper caching strategy should be implemented.


java j2ee job interview questions with answers | Learn the core concepts and the key areas
 
wood burning stoves
 
subject: core java