Interview
- 22 June
Restful web services interview questions
Restful web services are very popular now a days because it is very simple to implement and less time consuming. In this post, we are going to see restful web services interview questions with answers. 1. What is REST? REST is an architectural style which was brought in by Roy Fielding in 2000 in his […]
- 19 June
Can We Have Try without Catch Block in Java
In Java, it’s possible to use a try block without a catch block, but it must be followed either by a finally block or be part of a try-with-resources statement. Let’s see both cases with the help of examples: 1. try-finally Structure You can use a try block with a finally block. As you may […]
- 07 June
Daemon thread in java with example
Daemon threads are low priority background threads which provide services to user threads. It’s life depends on user threads. If no user thread is running then JVM can exit even if daemon threads are running. JVM do not wait for daemon threads to finish. Daemon threads perform background tasks such as garbage collection, finalizer etc. […]
- 03 June
How to check if String has all unique characters in java
Learn about how to check if String has all unique characters in java
- 19 May
Java transient keyword with example
Transient variable is the variable whose value is not serialized during serialization. You will get default value for these variable when you deserialize it. Lets say you have Country class and you don’t want to Serialize population attribute as it will change with time, so you can declare population attribute as transient and it won’t […]
- 18 May
ArrayList in java
ArrayList in java is most common Collections data structure along with HashMap which we use very often. 1. Why to choose ArrayList vs Array: Array is fixed length data structure If array is full , you can not add element to it, where as ArrayList in java can dynamically grow and shrink as per our […]
- 17 May
How to check if one String is rotation of another String in java
In this post, we will see how to check if one String is rotation of another or not. For example: [crayon-6768a44b6c347616006237/] Approach: Lets say you need to check whether str1 and str2 is rotation of one another or not. Create a new String with str3= str1 + str1 Check if str3 contains str2 or not. […]
- 17 May
Can we call run() method directly to start a new thread
No, you can not directly call run method to start a thread. You need to call start method to create a new thread. If you call run method directly , it won’t create a new thread and it will be in same stack as main. Lets understand with the help of example: [crayon-6768a44b6c461687234713/] When you […]
- 16 May
Can we start a thread twice in java
No, Once you have started a thread, it can not be started again. If you try to start thread again , it will throw IllegalThreadStateException Lets understand with the help of example: [crayon-6768a44b6c506135410214/] When you run above program , you will get below output: Thread is runningException in thread “main” java.lang.IllegalThreadStateException at java.lang.Thread.start(Thread.java:705) at org.arpit.java2blog.StartThreadAgainMain.main(StartThreadAgainMain.java:16) […]