Introduction to Java Classes, field and Objects

Introduction to Java Classes, field and Objects

Previous Home Next

 


J
ava is an object-oriented language. "Object-oriented" is a term that has become so commonly used as to have practically no concrete meaning.
here we discuss the intro of java class,field and objects

Java classes
 A class can contain fields and methods to describe the behavior of an object.Or
A class is a collection of data and methods that operate on that data.
The data and methods, taken together, usually serve to define the contents and capabilities of some kind of object.

Java Fields
Fields are used to store the data for the object and combined they make up the state of an object.
As we're making a Car object it would make sense for it to hold data about the Car's name, model, company name

Java Objects.
An object is an instance of a class created using a new operator. The new operator returns a reference to a new instance of a class. This reference can be assigned to a reference variable of the class.
 


 
public class Car // class is declared as car
{

//fields
private String name;
private String model;
private String companyname;
}


Previous Home Next