Core Java - Interview Questions and Answers for 'Return statement' | Search Java Interview Question - javasearch.buggybread.com
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

   



Core Java - Interview Questions and Answers for 'Return statement' - 3 question(s) found - Order By Newest

 Q1. Does it make sense to have return statement at the end of method ?Core Java2016-11-25 09:42:48

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

  Overridden methods must have the same ...
  Which of the following is false about Constructors ?
  what is covariant return type?
 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 ?


 Q2. What is the difference between return and continue statement ?Core Java2017-07-23 13:17:08

Ans. return is used within a method to return control out of the method. It may be followed by a value which is returned from the method to calling method immediately preceding the point of call.

continue statement is used within a loop to start next iteration without executing the remaining statements in the loop.

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

   Like         Discuss         Correct / Improve     return statement  continue statement  return vs continue  for loop  control statements  loop statement


Related Questions

  What are the considerations to be made in case of loops in Java ?
  What is the difference between a break statement and a continue statement?


 Q3. What is the difference between return and break statement ?Core Java2017-07-23 13:18:19

Ans. return is used within a method to return control out of the method. It may be followed by a value which is returned from the method to calling method immediately preceding the point of call.

break statement is used within a loop to move control out of the loop.

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

   Like         Discuss         Correct / Improve     return statement  break statement  return vs break


Related Questions

 What will happen if we don't have termination statement in recursion ?
  What are the considerations to be made in case of loops in Java ?
  What is the difference between a break statement and a continue statement?
  What you do to make sure that your project doesn't break in Jenkins ?
 In the following code, which text will get printed immediately after Hello

for(int countx=0;countx<10;count++){
System.out.println("World");
for(int countx=0;countx<10;count++){
System.out.println("Friend");
for(int countx=0;countx<10;count++){
System.out.println("Hello");
break;
}
System.out.println("Buddy");
}
}
 What are the ways to break singleton pattern ?
 How serialization breaks Singleton pattern ?
 How Reflection can break any design pattern ?
 When singleton can break and how to resolve it



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: