Java

Java program to print student details using constructor1 min read

Constructors are special methods in Java that are automatically called when an object of a class is created to initialize all the class data members. If there are no explicitly defined constructors in the class, the compiler creates a default constructor automatically.

Default Constructor: A default constructor takes no arguments. Each object of the class is initialized with the default values that are specified in the default constructor. Therefore, it is not possible to initialize the different objects with different values.




Java Code:

Output:

Java program to print student details using constructor
Java program to print student details using constructor

Leave a Comment