Encapsulation in Java is achieved when each object keeps its state private, inside a class.

Yogis answer the questions, “Who am I?” and “What is life?”.

In this example, the human class objects of consciousness, thoughts, senses, hunger, energy, and talk,
are private… creating encapsulation.

This example illustrates how, in different human activities, the private objects of consciousness, thoughts,
senses, hunger, energy, and talk are increasing or decreasing… active or inactive.

The activity of yoga, or meditation, has unique states.
During meditation, consciousness transforms from normal consciousness, to super consciousness, to
cosmic consciousness.  There are no thoughts.  There is no body awareness.
There is union with divine energy.

Java NetBeans project Encapsulation:

/*
each object keeps its state private, inside a class
*/
class Human {
// private variables that can only be accessed by
// public methods of this class
private String consciousness;
private String thoughts;
private String senses;
private String hunger;
private String energy;
private String talk;

// get method for access to
// private variable consciousness
public String getConsciousness() {
return consciousness;
}

// get method for access to
// private variable thoughts
public String getThoughts() {
return thoughts;
}

// get method for access to
// private variable senses
public String getSenses() {
return senses;
}

// get method for access to
// private variable hunger
public String getHunger() {
return hunger;
}

// get method for access to
// private variable energy
public String getEnergy() {
return energy;
}

// get method for access to
// private variable talk
public String getTalk() {
return talk;
}

// set method for access to
// private variable consciousness
public void setConsciousness(String newConsciousness) {
consciousness = newConsciousness;
}

// set method for access to
// private variable thoughts
public void setThoughts( String newThoughts) {
thoughts = newThoughts;
}

// set method for access to
// private variable senses
public void setSenses(String newSenses) {
senses = newSenses;
}

// set method for access to
// private variable hunger
public void setHunger(String newHunger) {
hunger = newHunger;
}

// set method for access to
// private variable energy
public void setEnergy(String newEnergy) {
energy = newEnergy;
}

// set method for access to
// private variable talk
public void setTalk(String newTalk) {
talk = newTalk;
}
}

public String yoga() {
Human h = new Human();
h.setConsciousness(“Cosmic Consciousness”);
h.setThoughts(“No Thoughts”);
h.setSenses(“No Senses”);
h.setHunger(“No Hunger”);
h.setEnergy(“Divine Energy”);
String yogaReturn;
yogaReturn = (h.getConsciousness() + “\r\n” + h.getThoughts() + “\r\n” + h.getSenses() + “\r\n” + h.getHunger() + “\r\n” + h.getEnergy());
return yogaReturn;
}

public String play() {
Human h = new Human();
h.setConsciousness(“Normal Consciousness”);
h.setThoughts(“Normal Thoughts”);
h.setSenses(“Normal Senses”);
h.setHunger(“Increasing Hunger”);
h.setEnergy(“Decreasing Energy”);
h.setTalk(“Talk!”);
String playReturn;
playReturn = (h.getConsciousness() + “\r\n” + h.getThoughts() + “\r\n” + h.getSenses() + “\r\n” + h.getHunger() + “\r\n” + h.getEnergy() + “\r\n” + h.getTalk());
return playReturn;
}

public String sleep() {
Human h = new Human();
h.setConsciousness(“Subconsciousness and Uconsciousness”);
h.setThoughts(“Dreams and No Thoughts”);
h.setSenses(“No Senses”);
h.setHunger(“Increasing Hunger”);
h.setEnergy(“Increasing Energy”);
String sleepReturn;
sleepReturn = (h.getConsciousness() + “\r\n” + h.getThoughts() + “\r\n” + h.getSenses() + “\r\n” + h.getHunger() + “\r\n” + h.getEnergy());
return sleepReturn;
}

public String eat() {
Human h = new Human();
h.setConsciousness(“Normal Consciousness”);
h.setThoughts(“Normal Thoughts”);
h.setSenses(“Normal Senses”);
h.setHunger(“Decreasing Hunger”);
h.setEnergy(“Increasing Energy”);
String eatReturn;
eatReturn = (h.getConsciousness() + “\r\n” + h.getThoughts() + “\r\n” + h.getSenses() + “\r\n” + h.getHunger() + “\r\n” + h.getEnergy());
return eatReturn;
}

public String work() {
Human h = new Human();
h.setConsciousness(“Normal Consciousness”);
h.setThoughts(“Normal Thoughts”);
h.setSenses(“Normal Senses”);
h.setHunger(“Increasing Hunger”);
h.setEnergy(“Decreasing Energy”);
h.setTalk(“Talk!”);
String workReturn;
workReturn = (h.getConsciousness() + “\r\n” + h.getThoughts() + “\r\n” + h.getSenses() + “\r\n” + h.getHunger() + “\r\n” + h.getEnergy() + “\r\n” + h.getTalk());
return workReturn;
}