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 is the difference between a switch statement and an if statement?
What is the use of StringTokenizer class?
difference between byte stream class and character stream class?
What is the method in java?
Explain wait() method of object class ?
Write a program to solve producer consumer problem in java?
Can we have multiple classes in single file ?
How to split a string in java?
What is parsing and its types?
Mention some interfaces implemented by linked list in java.
Where import statement is used in a java program?
According to java operator precedence, which operator is considered to be with highest precedence?
What is an argument in java?
What is the collections api in java programming?
What do you understand by an io stream?