What is encapsulation? Elaborate with example?
Answer / devarathnam.c,kotagudibanda,ka
Hi,
Encapsulation: The wrapping up of a data and methods into a
single unit is called Encapsulation. You can achieve
Encapsulation by using private data and public methods look
at the following example for better understanding.
Eg:
public class EcapTest{
public static void main(String args[]){
private int a=22;
private String s="DEVARATHNAM";
private float f=33.24f;
public void displayData(){
// some code
}
public void getData(){
// some code
}
}//main
{//class.
Observe the above program we are combining both data and
methods into a single unit(EcapTest). I hope i met your
needs.
| Is This Answer Correct ? | 23 Yes | 5 No |
What are static blocks and static initalizers in java ?
What is jar?
why java does not support mulitple inheritance directly?
What is Locale class?
What are the steps in the jdbc connection?
What is object-oriented paradigm?
What is module in project?
What is the applet security manager, and what does it provide?
Why is string buffer better than string ?
Difference between the String and StringBuffer classes?
Tell me the programme for this @ 1 2 @ @ @ 1 2 3 4
5 Answers Accenture, iGate, IntoNET, Value Labs,
Which of these methods belong to Thread & Object class? join, yield, sleep, wait, notify