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
What are encapsulation, inheritance and polymorphism?
What is a parameter used for?
explain what is transient variable in java?
What are the differences between heap and stack memory?
What is instance synchronization?
What comes to mind when someone mentions a shallow copy in java?
What is abstract class? Explain
Is an integer an object?
What is string english?
what are the high-level thread states? : Java thread
how does multithreading take place on a computer with a single cpu? : Java thread
Is java written in c?
What is meant by main method?
What is not object oriented programming?
What is a package in java? List down various advantages of packages.