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
How much ram can a 64 bit processor theoretically?
What is the base class of all exception classes?
What is the association?
What are java methods?
How many tetrahedral voids are there in bcc?
What is the protected method modifier?
Write a function for palindrome and factorial and explain?
What is default exception handling in java?
Is it possible to specify multiple jndi names when deploying an ejb?
What is the main purpose of serialization in java?
What is the generic function?
How can constructor chaining be done using this keyword?
Tell us something about set interface.
What are the practical benefits, if any, of importing a specific class rather than an entire package (e.g. Import java.net.* Versus import java.net.socket)?
Is there any way to skip finally block of exception even if some exception occurs in the exception block?