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

Answers were Sorted based on User's Feedback



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

Answer / 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

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

Answer / ramanareddy333

simply it will considered as a normal method in the class

Is This Answer Correct ?    19 Yes 1 No

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

Answer / tntrichy

Answer 3 is wrong

Is This Answer Correct ?    9 Yes 1 No

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

Answer / rajesh

Nothing to be happen
the program might compile the output wont come.

Is This Answer Correct ?    9 Yes 3 No

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

Answer / krishna kumar g.

Answer 2 is exactly correcr.I have done practiclly.No
compile time errors.
Code will run and executes sucessfully.But it treats as
method not as constructor.

Is This Answer Correct ?    5 Yes 1 No

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

Answer / sasikumar m

If return type is mentioned, then that will become a normal
method. Otherwise that will be considered as a constructor.

Is This Answer Correct ?    6 Yes 2 No

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

Answer / amir

answer 3 is 100% right... it will compile time error
constructor cannot have return type specification

Is This Answer Correct ?    2 Yes 0 No

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

Answer / shankar

*A constructor is a special method which has the same name
as that of the class which is used for the initialising and
instance,when it is being created itself.

*Normal method may or may not returns values when a normal
method does not return value it is mentioned explicitly
with void keyword

**ANSWER**-- 7 is write

Is This Answer Correct ?    1 Yes 1 No

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

Answer / susheel s

Answer 3 is absolutely right becuse compiler strictly
follows the syntax. Except answer 3 all are wrong.

Is This Answer Correct ?    2 Yes 8 No

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

Answer / ravikiran

runtime exception will be raised

Is This Answer Correct ?    2 Yes 9 No

Post New Answer

More Core Java Interview Questions

What is the difference between hashset and treeset in java?

0 Answers  


What is a predicate method?

0 Answers  


"we cannot create an object of interface but we can create a variable of it".diacuss the statement with the help of an example.

2 Answers  


Is empty list java?

0 Answers  


What is the use of volatile in java?

0 Answers  






What is the constructor?

0 Answers  


Difference between object instantiation and construction ?

0 Answers  


How we can make copy of a java object?

0 Answers  


static inner classes means..?

1 Answers  


how is final different from finally and finalize in java?

0 Answers   DELL,


Can we catch more than one exception in single catch block?

0 Answers  


What is the difference between variable & constant?

0 Answers  


Categories