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
How to convert string to byte array and vice versa?
What is null statement?
Can a static class have a constructor java?
How do you initialize an arraylist in java?
What are the rules for naming an array?
What are java threads?
Explain restrictions for using anonymous inner classes?
Give an example of use of pointers in java class.
How does map works in java?
Explain the difference between comparator and comparable in java?
What is the meaning of 3 dots in java?
What happens when a thread cannot acquire a lock on an object in java programming?
What is an object class?
Can an integer be null java?
What Is Composition?