
suppose i hava a class:
public class Student{ private int rollNo; private String name; }
then what would be the default constructor:
1) public Student(){ private int rollNo = 0; private String name = null; }
or
2) public Student(){ private int rollNo; private String name; }

hi friend,
Constructors in a class are used to create objects from the class blueprint. new keyword is used to create the space in memory and initializes the fields. So, in the default constructor you can initializ your fields with a value or you can simply create a constructor by calling super().
In your case Constructor of your class should be as follows :
public Student()
{
rollNo = 0;
name = null;
}
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.