Does all methods need to have a return type ? Is it applicable to constructors too ?
Javasearch.buggybread.com

Search Interview Questions


 More than 3000 questions in repository.
 There are more than 900 unanswered questions.
Click here and help us by providing the answer.
 Have a video suggestion.
Click Correct / Improve and please let us know.
Label / Company      Label / Company / Text

   



Java - Interview Questions and Answers

 Q1. Does all methods need to have a return type ? Is it applicable to constructors too ?Core Java2017-05-13 19:59:44

Ans. All methods are not expected to return something but Yes, all methods are expected to have a return type. If a method returns nothing, it can be declared with the return type void.

Constructors are not expected to have any return types , not even void.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     return type   method  constructor


Related Questions

  Overridden methods must have the same ...
  Which of the following is false about Constructors ?
  what is covariant return type?
 Why doesn't Java even allow void return types for Constructors ?
 What is void in Java ?
 What is the difference between the 2 methods in Java ?

Class BuggyBread {

BuggyBread(){
}
void BuggyBread(){
}
}
 Can we change return type of Overridden method ?
 Can methods without a return type be declared in Java? Is there a difference between void return type and no return type ?
 Can we set specific return type of a method in typescript ?



Help us and Others Improve. Please let us know the questions asked in any of your previous interview.

Any input from you will be highly appreciated and It will unlock the application for 10 more requests.

Company Name:
Questions Asked: