adspace
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 if I write static public void instead of public static void?
What do you understand by casting in java language? What are the types of casting?
Can we extract main method from another class?
What is the locale class?
How does java handle integer overflows and underflows?
what is reflection api? How are they implemented?
What is the java api?
Are jvm’s platform independent?
What is the first argument of the string array in main method?
What is the resourcebundle class?