KEMBAR78
Constructor | PDF
0% found this document useful (0 votes)
26 views1 page

Constructor

Uploaded by

nagendra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views1 page

Constructor

Uploaded by

nagendra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

[10:57 AM] Sandhya Singh

class Student
{
String name;
Student() // default constructor
{

}
Student (String name) // Parameterized Constructor
{
this.name =name;// this refer the current instance class member
}
void display()
{
System.out.println("Name"+name);
}
}
class Main
{
public static void main()
{
Student stud =new Student(); //calling default constructor
Student stud =new Student("Mac"); // calling Parameterized constructor
}
}

You might also like