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
What is cdi in java?
What's the difference between local, global and universal groups? : java security
What is the difference between Logical Parallelism and Physical Parallelism?
What are the types of cookies in java?
What is lambda used for?
What is native class in java?
What about 'hostile applets'? : java security
What is entitymanager in java?
Why do we need new date and time api in java se 8?
How should I format my code? How should I comment my code?
What is the difference between swing and awt components?
What is hql in java?
How do I install java on windows?
What is xml file in java?
How do you run an executable jar file?