Java - Interview Questions and Answers for 'Return' | Search Java Interview Question - javasearch.buggybread.com
Javasearch.buggybread.com
Share

Search Java Interview Questions


 2137 questions in repository.
 There are more than 200 unanswered questions.
Click here and help us by providing the answer.
Label / Company      Label / Company / Text

   



Interview Questions and Answers for 'Return' - 8 question(s) found - Order By Newest

 Q1. what is covariant return type? Core Java
Admin
info@buggybread.com
Ans. co-variant return type states that return type of overriding method can be subtype of the return type declared in method of superclass. it has been introduced since jdk 1.5

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

   Like      Discuss      Correct / Improve     java   oops   inheritence   overriding   covariant return type   jdk5   advanced     Hewlett Packard (HP)  The Systems Group  Evergent      expert


 Q2. What is the use of return statement without any argument ?Core Java2016-11-25 09:40:47

Ans. Such return is only expected in methods that returns void. the purpose of having return in such a method is to return the flow out of method and return to the place where it was called. Its actually used to prematurely return the control from the method.

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

   Like      Discuss      Correct / Improve     return


 Q3. 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


 Q4. What is void in Java ? Core Java2017-05-13 19:58:10

Ans. void is a return type which indicates that the method returns nothing but returns the control to the line next to the method call. All methods need to have a return type and hence a method returning nothing needs to be declared void.

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

   Like      Discuss      Correct / Improve     void  return type


 Q5. 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


 Q6. What is the difference between the 2 methods in Java ?

Class BuggyBread {

BuggyBread(){
}
void BuggyBread(){
}
}
Core Java2017-05-13 20:02:27

Ans. BuggyBread method without any return type is the constructor which get's called upon object creation whereas BuggyBread method with return type of void is just another method that needs to be called explicitly for it's invocation.

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

   Like      Discuss      Correct / Improve     method  return type  constructor


 Q7. 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


 Q8. 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




Subscribe to Java News and Posts. Get latest updates and posts on Java from Buggybread.com
Enter your email address:
Delivered by FeedBurner



comments powered by Disqus
 

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:
         

X Close this

X Close this

Help Us Improve.
Please share your
interview experience.

Company Name:   


Questions Asked: