what is constructer?what are the type of constructer with
example.
Answer Posted / shiva krishna
class Shiva
{
public Shiva() // it is a constructor
{
//code
}
}
class Mainclass
{
public static void main(String args[])
{
Shiva obj=new Shiva();
}
}
explanation: the code written in constructor is
automatically executed when we create object for the
class.no need to call the constructor/method again.
point to note:
constructor must not have any return type
| Is This Answer Correct ? | 1 Yes | 1 No |
Post New Answer View All Answers
Is java an api?
What is ioexception in java?
What kind of thread is the garbage collector thread?
What is the difference between a jdk and a jvm?
How do I export a java project?
What is data persistence in java?
What is jar file in java?
Why we use beans in java?
How does jpa repository work?
What is factory pattern in java?
What do you understand by downcasting?
Name primitive java types.
What is loose coupling in java?
What is @qualifier in java?
Explain the common use of ejb?