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 charat is used in java?
How many threads can I run java?
What methodology can be utilized to link to a database?
How does callback work in java?
Where and how can you use a private constructor?
Which is better stringbuilder or stringbuffer?
What do bitwise operators do?
What do you mean by singleton class in java?
What do you mean by access modifier?
What is array in java?
What is the constructor?
Can you pass functions in java?
What is the length of a string?
Explain about fail safe iterators in java?
Explain about main thread in java?