What is meant by Encapsulation? Can you write a class to
explain encapsulation?

Answer Posted / rajasekhar

It is the ability of an object to hide its data and methods
from the rest of the world.

A Class may contains a few members in the form of
properties,events,fields or methods.These members of the
class are not exposed to the outer world directly.Rather
they are ENCAPSULATED by the Class.

Public Class Calculations
{
Private void fnMultiply(int x, int y)
{
return x*y;
}
}

Calculations Obj;
int Result;
Result = Obj.fnMultiply(5,10);

Is This Answer Correct ?    19 Yes 10 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is parse method?

544


How many threads can java run?

561


State the difference between creating string as new () and literal.

524


What happens when main () method is declared as private?

650


What does a boolean method return?

633






What does the ‘static’ keyword mean? Is it possible to override private or static method in java?

567


Can a method be overloaded based on different return type but same argument type?

547


What is native code?

538


Explain 5 features introduced in jdk 1.7?

613


What is thread life cycle in java?

586


How do you identify independent and dependent variables?

507


Is it possible to override the main method?

535


how a programmer confirms that the data submitted has been succesfully inserted into the database(either oracle or my sql).. How a programmer confirm if there is any problem with the program he wrote for insertion... ANS:--- >executeupdate method is having boolean return type, if anything goes wrong in data insertion or data updation, it would return false. otherwise, if it successfully inserts data into the database, it would return true NOW HOW TO I CHECK IN MY DURING EXECUTION WHETHER IT RETURNS TRUE OR FALSE... WELL IT WILL DISPLAY ANY MESSAGE OR NOT

1853


What about anonymous inner classes in java?

563


Why map is used in java?

583