2. What is Constructor?
A constructor in Java is a special method
that is used to initialize objects.
The constructor is called when an object of
a class is created.
4. DEFAULT CONSTRUCTOR
The Default Constructor is a constructor that either
has no parameters, or if it it has parameters all
parameters have default values. If there is no
Constructor in a class, Compiler automatically
creates a Default Constructor
6. PARAMETRIZED CONSTRUCTOR
A constructor having a specific number of
parameters(arguments) is called a
parameterized constructor.
The parameterized constructor is used to
provide different values to the objects, you can
also provide the same values.
7. class Student
{
int rollno;
String name;
void display()
{
System.out.println(rollno);
System.out.println(name);
}
public static void main(String...s)
{
Student ss = new Student();//creating object of Student class
ss.void();//calling method
}
}