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

Is jdk required for netbeans?

665


In java thread programming, which method is a must implementation for all threads?

726


Topic- looping,function overloading,nesting ,polymorphism. Aim - to write a function with a name buzz-buds,that will check whether the given numbers are buddies or not on the basis of no. of parameters passed during function calling.

1813


What is the locale class?

711


What is the difference between a jvm and a jdk?

745


What are the advantages of java sockets?

856


What does public static void main(string[]) mean?

726


What is map and flatmap?

784


How do you run an executable jar file?

665


What is the difference between java se and java ee?

593


How can c# app request minimum permissions? : java security

624


What is the difference between ec2 and lambda?

654


What gives java it’s “write once and run anywhere” nature?

776


How do you type the lambda symbol?

669


What are the rules regarding quotation marks?

652