Here is a class Encapsulate
which has public property and a public method.
class Encapsulate
{
public int a;
public int b;
public static void main(String...s)
{
Encapsulate e = new Encapsulate();
e.setVar(10,20);
System.out.println(e.getSome());
}
public void setVar(int a, int b)
{
this.a = a;
this.b = b;
}
public int getSome()
{
return a + b;
}
}
Is the OOP concept Encapsulation
followed here?
I am sure that it is applicable as both are bonded together in a class, may be we can call it weak encapsulation but there is encapsulation.
But I don't know how to prove it because my searches showed that class properties should be private.
Update : What in case of default access specifier.