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 do you read and print a string in java?
How can we create an immutable class in java?
What is appletviewer?
When can we say that threads are not lightweight process in java?
What is the major difference between linkedlist and arraylist?
What is meant by tab pans?
Can we call virtual funciton in a constructor ?
If a class is declared without any access modifiers, where can the class be accessed?
describe synchronization in respect to multithreading? : Java thread
How many bits is size_t?
What does three dots mean in java?
Do I need to import java.lang package any time? Why?
What is an empty string in css?
What are the differences between c++ and java?
How can we run a java program without making any object?