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

Answer Posted / srinu

Encapsulation=DataHidding+Abstraction is called
Encapsulation is called Encapsulation

EX:-
public class A
{
private String name;
private int age;
publiic setName(String name)
{
this.name=name;
}
public String getName()
{
return name;
}
public setAge(int age)
{
this.age=age;
}
public int age()
{
return age;
}
}

Is This Answer Correct ?    6 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Is .net better than java?

565


What are the differences between string, stringbuffer and stringbuilder?

531


Can we extend private class in java?

555


Can the interface be final?

586


Define nashorn in java8.

570






How do you initialize an arraylist in java?

515


What is mean by exception?

555


What is JFC?

718


What does it mean that strings are immutable?

582


What is the major difference between linkedlist and arraylist?

514


What is the difference between equals() and?

595


Define linked list and its features with signature?

547


what is the difference between thread and runnable types? : Java thread

554


What are the default and parameterized constructors?

562


How infinite loop is declared?

543