Difference between table scan, index scan, and index seek in Database

Good understanding of Indexes is very important while working in a database and SQL and that's why you will find many questions based upon indexes on Programming Job interviews. One of such frequently asked SQL question is the real difference between table scan, index scan, an index seek? which one is faster and why? How does database chooses which scan or seek to use? and How you can optimize the performance of your SQL SELECT queries by using this knowledge. In general, there are only two ways in which your query engine retrieves the data, using a table scan or by using an index. Which method is used for your particular query depends upon what indexes are available in that table, what columns you are requesting in your query, the kind of joins you are doing, and the size of your tables.

How to Reverse String in Java with or without StringBuffer Example

Reverse String in Java
There are many ways to reverse String in Java. You can use rich Java API to quickly reverse contents of any String object. Java library provides StringBuffer and StringBuilder class with reverse() method which can be used to reverse String in Java. Since converting between String and StringBuffer or StringBuilder is very easy it's the easiest way available to reverse String in Java. At the same time, Writing Java program to reverse String in Java without StringBuffer is one of the popular Java String interview question, which requires you to reverse String by applying logic and by not using API methods.

How to create and initialize List or ArrayList in one line in Java

creating and initializing List in same time
Sometime we want to create and initialize List like ArrayList or LinkedList in one line much like creating array and initializing it on same line. If you look Array on Java programming language you can create and initialize both primitive and object array e.g. String array very easily in just one line but in order to create a List equivalent of that array, you need to type lot of code. This is also one of the tricky Java question some time appears in Interview as Write Java code to create and initialize ArrayList in same line. In this Java tips we will see this trick which allow you to create and initialize List much like an Array. This tip can also save lot of time while creating test program or quickly trying some stuff.

What is difference between Thread vs Process in Java

Thread and Process are two closely related term in multi-threading and main difference between Thread and Process in Java is that Threads are part of process. i.e. one process can spawn multiple Threads. If you run a Java program in UNIX based system e.g. Linux and if that program creates 10 Threads, it still one process and you can find that by using ps -ef | grep identifier command which is one of most popular use of grep command in UNIX, Where identifier is unix text which can be used as regular expression to find that Java process. Another major difference between Process and Thread is that, each process has its own separate memory space but Threads from same process same memory space. Some linux command map Java thread with light weight process or lwp, e.g. if you use prstat command in Solaris, you can get how many light weight process or Thread a particular Java program is using.