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. |
|
| |||||||||||
Interview Questions and Answers - Order By Newest | |||||||||||
| |||||||||||
Ans. Sometimes the calls move across layers of classes and functions and hence each layer needs to perform some function like cleaning if something goes wrong deep inside. | |||||||||||
Help us improve. Please let us know the company, where you were asked this question : | |||||||||||
Like Discuss Correct / Improve  exceptions  exceptions handling  rethrowing exception | |||||||||||
| |||||||||||
Ans. never initialise local to null,yes it is bad pratice | |||||||||||
Help us improve. Please let us know the company, where you were asked this question : | |||||||||||
Like Discuss Correct / Improve  null  nullpointerexception | |||||||||||
| |||||||||||
This question is still unanswered. Can you please provide an answer. | |||||||||||
Help us improve. Please let us know the company, where you were asked this question : | |||||||||||
Like Discuss Correct / Improve  ArithmeticException | |||||||||||
| |||||||||||
Ans. The regular behavior of exception handling will occur. It will look for any immediate catch handler and if none is provided, it would be transmitted to the callers until a catch handler is found or it's out of main function. | |||||||||||
Help us improve. Please let us know the company, where you were asked this question : | |||||||||||
Like Discuss Correct / Improve  exceptions  finally | |||||||||||
| |||||||||||
This question is still unanswered. Can you please provide an answer. | |||||||||||
Help us improve. Please let us know the company, where you were asked this question : | |||||||||||
Like Discuss Correct / Improve  exception handling | |||||||||||
| |||||||||||
Ans. It's an exception that is thrown when we attempt to add value of an incompatible type to an array. For example - Object[] strArray = new String[2]; strArray[0] = 5; In this code, strArray reference of type Object has currently been assigned the String array but at line 2 we are trying to add an integer value. | |||||||||||
Help us improve. Please let us know the company, where you were asked this question : | |||||||||||
Like Discuss Correct / Improve  arrays   ArrayStoreException | |||||||||||
| |||||||||||
Ans. No. But It will throw ArrayStoreException at runtime. | |||||||||||
Help us improve. Please let us know the company, where you were asked this question : | |||||||||||
Like Discuss Correct / Improve  ArrayStoreException  arrays | |||||||||||
| |||||||||||
Ans. ExceptionHandler is Used to handle at Method level | |||||||||||
Help us improve. Please let us know the company, where you were asked this question : | |||||||||||
Like Discuss Correct / Improve  @ExceptionHandler | |||||||||||
| |||||||||||
Ans. If we do not mention, Cloneable Interface to the Class which we want to Clone then we get this exception, only if we try to clone an object Like: public class TestClone{ @Override protected Object clone() throws CloneNotSupportedException { return super.clone(); } } In Main, You try to do: TestClone clone = new TestClone(); TestClone clone2 = (TestClone) clone.clone(); You will get CloneNotSupportedException. Just add -> public class TestClone implements Cloneable { and things are fixed. | |||||||||||
Help us improve. Please let us know the company, where you were asked this question : | |||||||||||
Like Discuss Correct / Improve  exceptions handling  cloning | |||||||||||
| |||||||||||
Ans. Returning from inside a finally block will cause exceptions to be lost. A return statement inside a finally block will cause any exception that might be thrown in the try block to be discarded. | |||||||||||
Help us improve. Please let us know the company, where you were asked this question : | |||||||||||
Like Discuss Correct / Improve  exception handling  finally block Asked in 1 Companies | |||||||||||
| |||||||||||
Ans. Throwable in java is a class that is the superclass of all exceptions and errors which may occurs in java program.It extends obcect class. | |||||||||||
Help us improve. Please let us know the company, where you were asked this question : | |||||||||||
Like Discuss Correct / Improve  exception handling   throwable Asked in 1 Companies basic | |||||||||||
| |||||||||||
Ans. Yes, We can pass the test even if the tested method throws an exception. One way is know as exception testing in which the tested method is expected to throw exception and hence the expectation is set accordingly. @Test(expected = IndexOutOfBoundsException.class) public void test(){} Other way is to just ignore if the tested code throws an exception. In that case , we can enclose the tested method call in the try block and within exception block, we just return gracefully. Exception testing is perfectly ok to be done as we would like test code in case an exception occurs and if the code is handling the exception properly. Ignoring the exception by putting the tested method call within try block isn't something normal and should be avoided. | |||||||||||
Help us improve. Please let us know the company, where you were asked this question : | |||||||||||
Like Discuss Correct / Improve  Junit exception testing | |||||||||||
| |||||||||||
| |||||||||||
| |||||||||||
| |||||||||||
| |||||||||||