Classes

  • class defines the attributes of objects
  • The values of an instance (i.e., object) variables define the internal state of an individual object
  • Class methods define the functionality it offers.
  • A class specifies what the objects instantiated from it are like.
    • The object’s variables (instance variables) specify the internal state of the object
  • The object’s methods specify what the object does
  • A class is defined to represent some meaningful entity, a real-world object or concept.
public class Person{
 
	private String name;
	private int age;
	
	public String getName(){
		return this.name;
	}
}
  1. Encapsulation : The keyword private means that the variables are “hidden” inside the object. This is known as encapsulation.