CoreJava-2 - Class, Method, Object and Variables
Core Java - Class, Method, Object and Variables 1 . what is a class in Java ? In Java, a class is a blueprint or a template for creating objects that define a set of data fields and methods that can be used to manipulate those data fields. Each object created from a class has its own unique set of data fields, which can be manipulated using the methods defined in the class. A class is defined using the "class" keyword, followed by the name of the class, and then the class body, which includes the data fields and methods. For example, the following code defines a simple class named "Person" with two data fields (name and age) and two methods (setName and setAge) for setting the values of these fields: public class Person { private String name; private int age; public void setName(String name) { this.name = name; } ...