What is the difference between REST and SOAP Web-service is a very popular question from Java J2EE interviews. I have myself asked this question a number of times. Here I am listing out some of the key differences between REST and SOAP purely from interview perspective i.e. I am only mentioning key points, not going into details. Unless you are doing exclusive work in REST or SOAP Web service, interviewer will not go into deep and if you have done the work already, you probably don't need this list. Anyway, let's see some key difference between REST and SOAP web service in Java.
Thursday, 31 December 2015
6 Difference between wait() and sleep() method in Java
Though both wait() and sleep() method are used to pause the running thread, here are some important difference between them:
1) The wait() method must be called from the synchronized context (can be a synchronized block or method) but sleep() method can be called from within our with-out synchronized block.
1) The wait() method must be called from the synchronized context (can be a synchronized block or method) but sleep() method can be called from within our with-out synchronized block.
Sunday, 8 November 2015
15 Advanced Core Java Interview Questions for Experienced Developers
In this article, I am going to share some advanced core Java interview questions for experienced programmers i.e. someone who has 2 to 5 years of experience in Java programming, mostly in core Java but JEE work is also fine. I have found that once you become senior and your experience grows, you no longer see questions like String vs StringBuilder or Vector vs ArrayList, instead many companies ask about class loaders, Garbage collectors, concurrency and about JVM. I have started collection some core Java questions for my preparation and today I am going to share some with you, I don't have their answer, So, I am looking forward to you guys to answer them, of course only if you know.
Saturday, 31 October 2015
How to sort an ArrayList on Increasing and Decreasing Order
In this Java tutorial, I will teach you how to sort an ArrayList on both increasing and decreasing order of elements. Though, we will use ArrayList of Integers on examples, you can practically sort any list by using this technique. Only requirement is that your object should implement Comparable interface otherwise you need to pass Comparator implementation to sort objects stored inside list. The sort() method is defined inside java.util.Collections class. It is overloaded to accept a Comparator. The version which doesn't take any argument sort the given list on default order e.g. increasing order for integers. This is defined by their compareTo() method which comes from Comparable interface. The version which takes Comparator, uses that to sort the list, as we have done to sort the list in reverse or decreasing order.
Saturday, 26 September 2015
How to Convert String to Date in Java in yyyy-MM-dd format
In this tutorial, I will show you how to convert String to Date in Java which is in yyyy-mm-dd format. We will use DateFormat and SimpleDateFormat class from java.util.text package for this conversion.
Here are the steps :
1) Create a DateFormat with format String as "yyyy-MM-dd" (remember, small "m" is for minutes, and capital "M" is for month)
2) Call the parse() method with given String, this will return a java.util.Date object
Here are the steps :
1) Create a DateFormat with format String as "yyyy-MM-dd" (remember, small "m" is for minutes, and capital "M" is for month)
2) Call the parse() method with given String, this will return a java.util.Date object
Saturday, 19 September 2015
Singleton Design Pattern using Double Checked Locking Idiom
In my last interview, I was asked to write code to implement Singleton design pattern using "Double checked locking" idiom, which I thought to share with you all. In Singleton design pattern, only instance of class is created during application lifetime and that's shared between all its clients. One of the challenge with Singleton pattern is to ensure that only instance of class is created without compromising performance.
How to convert String to int and Integer in Java? An Example
There are two main way to convert a String to int primitive and Integer class in Java :
1) Integer.parseInt(), which takes a String and return an int primitive
2) Integer.valueOf() ,which accept a String and return an Integer object
1) Integer.parseInt(), which takes a String and return an int primitive
2) Integer.valueOf() ,which accept a String and return an Integer object
Subscribe to:
Posts (Atom)