Member-only story
CORE JAVA INTERVIEW QUESTIONS AND ANSWERS
JAVA INTERVIEW QUESTIONS
1. Q : WHAT IS DATA HIDDING ?
ANS : Hiding of the data so that outside person can’t access our data directly.
By Using private modifier we can implement data hiding.
Ex :
class Account {
private double balance =1000;
}
The main advantage of Data Hiding is we can achieve security.
2. Q : WHAT IS DATA ABSTRACTION ?
ANS : Hiding internal implementation details & just highlight the set of services . What we are offering is called abstraction.
Ex :
Bank ATM Machine.
By using interfaces & abstract classes we can achieve abstraction.
The main advantage of abstraction are :
- 1. We can achieve security as no one is allowed to known our internal implementation.
- 2. Without effecting outside person we can change our internal implementation. Hence Enhancement will become very easy.
3.Q : WHAT IS ENCAPSULATION ?
ANS : Encapsulating data & corresponding methods into a single module is known as encapsulation.
If any java class follows Data Hiding and Abstraction such type of class is said to Encapsulated class.
Encapsulation = Data Hiding + Abstraction.
class Account {…