Tightly encapsulated Class:
A class is said to be tightly encapsulated. If and only if each and every variable of class declared as private.
And there is no need to be worry about whether class contains : corresponding getter and setter methods or not; or whether these methods are declare as public or not.
And there is no need to be worry about whether class contains : corresponding getter and setter methods or not; or whether these methods are declare as public or not.
for example :
example1
public class Account{
private double balance;
public double getBalance()
{
return balance;
}
}
example2
public class A{
private int x=0;
}
class B extends A
{
int y=20;
}
}
in the above example2 B class is not a tightly encapsulated class. because y variable is not declared as private.
No comments:
Post a Comment