Blog Archives

Java exception handling interview questions and answers

Q1. What is the difference between a runtime exception and a checked exception? A1. You must either catch or throw a checked exception. The unchecked exception (aka Runtime exception) does not have to be explicitly handled. Q. So, when to use checked exception, and when to use unchecked exception? A….



Java String & Array limitations and OutOfMemoryError

Q1. What is the maximum possible length of a Java String & how much heap space do you need to store the maximum possible String object?
A1. A Java String internally uses a char array (i.e. char[]) and the indices of an array is an integer. The maximum value of an integer is Integer.MAX_VALUE, which is 2^31 – 1 (or approximately 2 billion). So, you can store a file up to 2 GB in size as a String, and for which you need at least 4 GB memory to store as each char is 2 bytes in Java, plus …



SQLException handling – recoverable & irrecoverable scenarios

Q1. What is wrong with SQLException? A1. When a SQLException occurs, you do not necessarily know what went wrong. It could be a temporary failure that correct itself with time like a database deadlock or rebooting server OR a permanent fault like bad SQL or missing columns in a table…



Top 5 Core Java Exceptions and best practices

#1: ConcurrentModificationException Getting a ConcurrentModificationException when trying to modify (i.e. adding or removing an item) a collection while iterating. The following code throws a ConcurrentModificationException.

Tags:

300+ Java & Big Data FAQs - Quick Prep

Java & Big Data Tutorials

Top