Exceptions in Java

Posted Posted in Core Java, Java

Exceptions in Java: Exceptions represent exception conditions that alter the normal program flow. Exceptions can be hardware failure, resource availability,or even code issues or bugs. Every exceptions an instance of a class that has Exception class in its inheritance hierarchy. So, exceptions are always some subclass of java.lang.Exception. Exception class again derives from class Throwable. […]

String immutability in Java

Posted 1 CommentPosted in Core Java, Java

String class: String class is immutable. String class is final so no one can modify behavior of any of the string methods. So, no body can override the String methods to alter the immutability. String Constant Pool Java maintains a pool of all string literals in order to minimize the memory usage and for better […]

Java Strings in switch statement

Posted Posted in Core Java, Java

Java started supporting Strings in switch statement since Java 7. Here is an example of using Strings in switch block : String status = "one"; switch(status) { case "one":         System.out.println("Choice one"); // Matching case         break; case "two:         System.out.println("Choice two");         break; default:         System.out.println("Choice other than one or two");         break; } Things to note here : 1) […]

set jdk path for SQL Developer

Posted Posted in Core Java, Java

This post can help you address the following issues : How to set Java path for SQL Developer tool ? How to set JDK path for SQL Developer tool ?   When you launch SQL Developer for the first time, it will ask you for JDK location, but once you point it to a JDK location it will […]

Singleton Design Pattern Questions

Posted Posted in Core Java, Java

What is Singleton Pattern ? Singleton pattern is used when we want to create only one instance of a class. A very simple example is say Logger, suppose we need to implement the logger and log it to some file according to date time. In this case, we cannot have more than one instances of […]

Java Interview Questions

Posted 3 CommentsPosted in Core Java, Interview questions, Java

For questions on Java Collections, see this post Java Collection Interview Questions. What is Null Pointer Exception in Java when there are no pointers in Java? When you declare a reference variable (i.e. an object) you are really creating a pointer to an object. Integer value; Here, we declare a variable named value, and it contains […]

Java Collections Interview questions

Posted 3 CommentsPosted in Core Java, Interview questions, Java

Difference between HashTable and HashMap HashMap is not threadsafe whereas HashTable is threadsafe Since HashMap is not synchronized it performs better than HashTable Hashtable does not allow null key, hashmap allows 1null key & several null values Iterator in hashmap is fail-fast. But enum in Hashtable is not fail-fast Fail-fast means if one thread is […]