The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Jul 2017 |
| Last Sign in: | 313 Weeks Ago, 5 Days Ago |
| Questions Answered: | 15833 |
| Tutorials Posted: | 15827 |
MBA,PHD, Juris Doctor
Strayer,Devery,Harvard University
Mar-1995 - Mar-2002
Manager Planning
WalMart
Mar-2001 - Feb-2009
1. What is recursion?
2. How do recursive calls to a method keep track of the parameter values and the values of local variables?
3. Write a recursive function to calculate the factorial of a number.
4. Write a recursive binary search for an array.
1. Assume that amt1 and amt2 are integers which have some values in them. Write a try-catch block that will try to divide amt1 by amt2 and put the result into a variable named quotient. If an ArithmeticException occurs, print a message saying “Invalid data” and set quotient to 0.
2. Assume that the main method has a try block that includes a statement which calls method1. Inside method1 is another try block that includes a statement which calls method2. Inside method2 is another try block that includes a statement which calls method3. What happens if method3 throws an exception? What happens if method2 has a catch block which can handle the exception? What happens if it does not have a catch block which can handle the exception? How does this progress if none of the methods can handle the exception?
----------- ----------- H-----------ell-----------o S-----------ir/-----------Mad-----------am ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- qu-----------ick-----------ly