waht happens when a return type ,even void is specified for
a constructor?

Answer Posted / chandra rekha

The constructor has the same name as that of the class to
which it belongs to. When a return type or void is
specified,no error occurs.It will be considered as a method.
for example:
public class myclass
{
public myclass()
...
}this is considered as a contrustor
whereas,
public class myclass
{
public void myclass()
{
...
}will be considered as a method.....

Is This Answer Correct ?    33 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Give the difference between the println method and sqrt method?

618


Difference between association, composition and aggregation?

550


Is java a super set of javascript?

573


How do you do exponents in java?

530


How many types of voids are there?

527






How is string immutable in java?

532


Name four container classes.

546


What are constructors in java?

560


how its run?

558


What are thread safe functions?

504


What is module in project?

507


Can we convert integer to string in java?

588


What is serial version uid and its importance in java?

591


What is Enum in Java?

673


Can we define private and protected modifiers for the members in interfaces?

528