Class: A blue print or template for creating a type of objects. Object: An instance of a class, also known as class object or class instance. It is made up of data and methods.
Declaration: Defines a variable’s name and type without assigning it a value. For objects, it means specifying the class type of the object reference name.
Instantiation: The new keyword is used and memory is allocated for an object, the reference to the object is created and returned from the new keyword.
Initialisation: The values put into the memory is allocated, this is what a constructor of a class does.
Initialisation process
The
new
keyword allocates memory for the person object. The constructor then initialises the newly allocated memory.
Default constructor
A default constructor is a no-argument constructor automatically provided by the Java compiler if no other constructors are explicitly defined in a class. The purpose of the default constructor is to ensure that every class has a constructor, allowing objects to be instantiated. Java takes back the default constructor once a constructor is explicitly defined by the programmer.
Back to parent page: Java Standard Edition (Java SE) and Java Programming
Web_and_App_Development Programming_Languages Java Class Object Default_Constructor
Reference: