#Constructor
Constructor
Constructor means name of the classes same but Parameter will be different.
Object does not to create of constructor
Program:
class First
{
void Display()
{
System.out.println("Hello world");
}
public static void main (String[] args)
{
First f1=new First();
f1.Display();
}
}
{
void Display()
{
System.out.println("Hello world");
}
public static void main (String[] args)
{
First f1=new First();
f1.Display();
}
}
Output:-
Hello World
First = Default Constructor,implicit constructor
Types Of Constructor
Default
Parameterized
Copy
Explicit Constructor:- Explicit Constructor are those constructor in which are declare or provide by user . These constructor are visible or declare outside of class .
Implicit Constructor:- implicit constructor are invisible.
Comments
Post a Comment