Real Time sample code for Encapsulation and Abstraction.
where to use abstract and where to use specifies like
public private.
Answer Posted / ravikiran
Encapsulation & Abstraction:
The private variable declaration is abstration,and making
usage of getters and setters is encapsulation
private String name="";
private String school="";
public String getName()
{
return name;
}
public void setName(String name)
{
this.name=name;
}
When We use private when we want to restrict the access
within the class.
When we use public then the variable or method will be
accessible in all the locations
| Is This Answer Correct ? | 18 Yes | 1 No |
Post New Answer View All Answers
Why are there no global variables in java?
Where are the card layouts used?
Can we have this () and super () together?
What are the types of exceptions?
What are the uses of synchronized keyword?
What is the core java?
How do you sort an array in java?
What does you mean in math?
What is the point of polymorphism java?
How does list work in java?
How does remove work in java?
Can you call a method in a method?
What is a function argument in java?
What is an inner class in java?
What is a vararg?