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


Please Help Members By Posting Answers For Below Questions

What is javax annotation generated?

474


What is meant by java se?

521


What is meant by annotations in java?

481


Where are group policies stored? : java security

486


Why do we need new date and time api in java se 8?

482






What is the locale class?

524


What is a stream in programming?

452


What is proxy object in java?

569


What is the use of servlet in java?

503


What is map and flatmap?

613


How do I enable java in google chrome?

447


What is mq in java?

482


Can we install jre without jdk?

508


Who is at risk in java? : java security

498


how can we create the ui using netbeans,having the code?

1627