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
Explain the selection sort algorithm?
Why do we need singleton class?
How are variables stored?
Is array a class in java?
Is java still necessary?
what is the difference between the methods sleep() and wait()? : Java thread
Can we override singleton class?
What is the symbol for average?
How do you allocate memory to object?
what is interface in java? Explain
What are classloaders?
What is the use of callablestatement?
What are keywords and reserved words in java?
How are multiple inheritances done in Java?
What is t type java?