Core Java - Interview Questions and Answers for 'Error' | Search 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 'Error' - 16 question(s) found - Order By Newest

 Q1. Explain java.lang.OutOfMemoryError ?Core Java
Ans. This Error is thrown when the Java Virtual Machine cannot allocate an object because it is out of memory, and no more memory could be made available by the garbage collector.

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

   Like         Discuss         Correct / Improve     java   exceptions   jvm   outofmemoryerror     Asked in 1 Companies


 Q2. When do you get ClassCastException?

or

What is ClassCastException ?
Ans. As we only downcast class in the hierarchy, The ClassCastException is thrown to indicate that code has attempted to cast an object to a subclass of which it is not an instance.

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

   Like         Discuss         Correct / Improve     java   oops   class casting   classcastexception   exception   error     Asked in 4 Companies      intermediate        frequent

Try 2 Question(s) Test


 Q3. Differences between class not found exception and noclassdef found error ?Core Java
Ans. ClassNotFoundException is an exception that occurs when we try to load a class at run time using Class.forName() or loadClass() methods and mentioned classes are not found in the classpath.

NoClassDefFoundError is an error that occurs when a particular class is present at compile time, but was missing at run time.

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

   Like         Discuss         Correct / Improve     exception handling  ClassNotFoundException  NoClassDefFoundError     Asked in 1 Companies


 Q4. What are some different logging levels for log4j ?Log4j
Ans. DEBUG
ERROR
ALL
WARN
INFO
FATAL
OFF
TRACE
TRACE_INT
WARN

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

   Like         Discuss         Correct / Improve     java   log4j   log4j level   logging   error logging     Asked in 10 Companies


 Q5. Which of the following exception is thrown when we try to access element which is beyond the size ?

a. NullPointerException
b. ArrayIndexOutOfBoundException
c. ArithmeticException
d. ParseException
Ans. ArrayIndexOutOfBoundException

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

   Like         Discuss         Correct / Improve     java   exceptions   error handling


 Q6. What will happen if static modifier is removed from the signature of the main method?
Ans. Program throws "NoSuchMethodError" error at runtime .

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

   Like         Discuss         Correct / Improve     java   main method   main   static   static method   nosuchmethoderror


 Q7. Tell me something about AssertionError ?Core Java
Ans. AssertionError is actually a fatal fault or a bug in the program. We may not like to continue program , request or thread execution if this error occurs as this condition is the assumption to continue further execution.

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

   Like         Discuss         Correct / Improve     java   error   exceptions   exception handling   assertion error   assertionerror


 Q8. Will this code compile ?

public class BuggyBread1{
abstract public void test();
}
Core Java
Ans. No. It will give the compilation error saying "The abstract method test in type BuggyBread1 can only be defined by an abstract class".

We need to declare the class abstract for it to have any abstract method.

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

   Like         Discuss         Correct / Improve     java   oops   abstract class   abstract methods   java compilation error


 Q9. Will this Code compile ?

abstract public class BuggyBread1{
abstract public void test(){};
}
Core Java
Ans. No. This will give a compilation error saying "Abstract methods do not specify a body".

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

   Like         Discuss         Correct / Improve     java   abstract classes   abstract methods   java compilation error   java coding   java code   coding   yes-no


 Q10. Name few Error and Exception classes provided by Java ?
Ans. http://www.buggybread.com/2015/01/java-list-of-error-exception-classes.html

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

   Like         Discuss         Correct / Improve     java   exceptions   error


 Q11. What is OutOfMemoryError in Java?Core Java
Ans. OutOfMemoryError in Java is a subclass of VirtualMachineError and is thrown by JVM when it runs out of heap memory.

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

   Like         Discuss         Correct / Improve     outofmemoryerror   error   exceptions   jvm   java   heap memory   heap


 Q12. When do we generally get this database error - integrity constraint violated - parent key not found ?
Ans. This error most likely will be thrown during an insert statement, while inserting a value within a foreign key column which doesnt exist within the Parent column. For example - Trying to add a dept number reference within a Employee Table when the Dept doesnt exist in the Dept Table.

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

   Like         Discuss         Correct / Improve     database  integrity constraint error  integrity constraint violated


 Q13. When do we generally get the database error - Unique Constraint Violated ?
Ans. This error can result either on an insert, update or delete when any change in data results in duplicate record or subset of it having unique constraint on record or its subset. For example - If we have a unique constraint on a combination of columns and then trying to insert duplicate column values.

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

   Like         Discuss         Correct / Improve     database  Unique Constraint error  Unique Constraint violated


 Q14. Difference between Error and Exception ?Core Java
Ans. An Error indicates serious problems that a reasonable application should not try to catch whereas

An Exception indicates conditions that a reasonable application might want to catch.

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

   Like         Discuss         Correct / Improve     error  exception handling  exceptions     Asked in 2 Companies      basic        frequent


 Q15. Can we catch errors in Java ? Core Java
Ans. Yes we can

try {
// code
} catch (Error ex) {
// handling code
}

but we shouldn't ideally do that as errors are mostly JVM based and not application based and there is rarely we can do something about it. Very likely catching and not re throwing would lead to muting their response or trace.

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

   Like         Discuss         Correct / Improve     exception handling  error handling  errors     Asked in 1 Companies      intermediate


 Q16. What is the difference between access and error log ?Logging
Ans. We log each access to the application resource within access logs, something like

"GET / HTTP/1.0" 200 113 "-" "Mozilla/5.0 zgrab/0.x" "-"

We log only error / warn messages within error logs, something like

ERROR 123#0: *19 connect() failed

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

   Like         Discuss         Correct / Improve     logging  access log  error log



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: