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

there are 67 seats in train . there are only 5 seats in a row and in last row there are only 2 seats. One person can reseve only 5 seat at a time. If person reserving seat , the care is atken that he may get all in row. if seats are not available in row then the arrangement is so that person group get nearby seats. the following class is given public class seat { char name; int seat; boolean isSeatempty } 1.Draw require class digram and object diagram. 2.Write function seatallot(int noofperson) to allocate seat with seat nuber printed for the each name.

3448


What is java persistence api used for?

448


What are the disadvantages of java sockets?

582


Which class is the superclass of every class?

521


How can the static main method use instance variables?

525






What is a container in java?

473


How do I enable java in firefox?

485


What is ehcache in java?

496


How do you type the lambda symbol?

491


What's the difference between authentication and authorization? : java security

503


What are the advantages of lambda functions?

475


What is an entity in java?

480


What is mdb in java?

509


How do I enable java in google chrome?

452


How do you run an executable jar file?

463