corejava8

36. How do you handle error condition while writing stored procedure or accessing stored procedure from java?
The stored procedure should return error code if some operation fails but if stored procedure itself fail than catching SQLException is only choice.

37.What is difference between Executor.submit() and Executer.execute()   method ?
Executor.execute():If your tasks throws an exception, then it will go to the uncaught exception handler (when you don't have provided one explicitly, the default one will just print the stack trace to System.err).        
Executor.submit():Any thrown exception, checked exception or not, is then part of the task's return status. For a task that terminates with an exception, the  Future.get ()will re-throw this exception, wrapped in an ExecutionException.

38.What is the difference between poll() and remove() method?
Both poll() and remove() take out the object from the Queue but if poll() fails then it returns null but if remove fails it throws Exception.

39. How do you print Array in Java?
Since array doesn't implement toString() by itself, just passing an array to System.out.println() will not print its contents,so by using the Arrays.toString() and Arrays.deepToString() method. but Arrays.toString() will print array with each element.


40. Which kind of tree is used to implement TreeMap in Java?
A Red Black tree is used to implement TreeMap in Java.

No comments:

Post a Comment