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

List some java keywords sun like c, c + + keywords?

0 Answers  


how to write a program for chat function using core java

1 Answers   Satyam,


what is multithreading?

5 Answers   Virtusa,


Is it necessary that each try block must be followed by a catch block?

0 Answers  


What are the procedures?

0 Answers  






Can an unreachable object become reachable again?

3 Answers  


what is mutual exclusion? How can you take care of mutual exclusion using java threads? : Java thread

0 Answers  


What is difference between Iterator and for loop

9 Answers   HP,


What is meant by class loader? How many types are there? When will we use them?

0 Answers  


What is Recursion Function?

0 Answers   iNautix,


What is the meaning of variable in research?

0 Answers  


Is void a data type?

0 Answers  


Categories