Does it make sense to have return statement at the end of method ?
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

   



Interview Questions and Answers

 Q1. Does it make sense to have return statement at the end of method ?Core Java
Ans. It make sense if its returning something. It doesnt make sense for void methods where return statement is not preceded by anything. In case of void methods , return as last statement has no impact and is actually a overhead.

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

   Like         Discuss         Correct / Improve     return statement  return


Related Questions

  what is covariant return type?
  Overridden methods must have the same ...
  Which of the following is false about Constructors ?
 What is the difference between these two approaches of creating singleton Class ?

//Double Checked Locking Code
public static Singleton createInstance() {
   if(singleton == null){
      synchronized(Singleton.class) {
         if(singleton == null) {
            singleton = new Singleton();
         }
      }
   }
   return singleton;
}

//Single checked locking code
public static Singleton createInstance() {
   synchronized(Singleton.class) {
      if(singleton == null) {
         singleton = new Singleton();
      }
   }
   return singleton;
}
 Write a method it will return reverse of the string(with out using reverse method of String or StringBuffer)
  Will static block for Test Class execute in the following code ?
  If you have access to a function that returns a random integer from one to five, write another function which returns a random integer from one to seven.
  Why is null == null returns true ?
 Can we have try statement without catch? If try statement contains return will the finally block be executed? What happens if there is an exception inside finally block?
 Does Constructor returns the reference of the newly created object ?



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: