Friday, April 22, 2016

Difference between notify and notifyAll in Java - When and How to use

notify vs notifyAll in Java
What is the difference between notify and notifyAll method is one of the tricky Java questions, which is easy to answer but once the Interviewer asks follow-up questions, you either got confused or not able to provide clear-cut and to the point answers? The main difference between notify and notifyAll is that the notify method will only notify one Thread and notifyAll method will notify all Threads which are waiting on that monitor or lock. By the way, this is something you have been reading all over places and to be frank,  this statement despite being correct is not complete, and it's very difficult to understand the difference between notify vs notifyAll by just reading this statement.

Tuesday, April 19, 2016

Difference between ExecutorService.submit() and Executor.execute() methods in Java?

What is the difference between Executor.submit() and Executor.execute() method in Java? is one of the good multi-threading questions for experienced Java programmers, mostly asked in Investment Banks like Barclays, Deutsche Bank, or Citibank. A main difference between the submit() and execute() method is that ExecuterService.submit()can return the result of computation because it has a return type of Future, but execute() method cannot return anything because it's return type is void. The core interface in Java 1.5's Executor framework is the Executor interface which defines the execute(Runnable task) method, whose primary purpose is to separate the task from its execution.

Sunday, April 10, 2016

Difference between Oracle SQL Query vs Microsoft SQL Server 2008 or Sybase

Oracle and Microsoft SQL Server are two of the most popular database but they are very different from each other and if you are migrating SQL queries or databases, tables from Oracle 11g database to Microsoft SQL Server 2008 then you are bound to face some issues. The main reason of these porting issues are features that are supported and exists in the Oracle database, but not available in Microsoft SQL Server 2008 like SEQUENCE, Order by clause in subqueries, and derived tables, derived table without a name, etc. I am sure there are few more and it will surface based upon different database objects you are using in your tables and queries.

What is purpose of different HTTP Request Types in RESTful Web Service?

RESTful web services heavily rely on HTTP by design. They use different HTTP methods to perform their job and uses an HTTP response code to inform clients about the success or failure of a particular request. REST stands for Representational State transfer and it uses HTTP to allow two systems to communicate via remote calls. RESTFul web services are a collection of REST URI which points to resources. These URI can point to a single resource of a collection of resources. For example, you would expect /employee/101 to contain details employee with 101 and /employees to return a list of all employees. In the RESTFul web service, HTTP request types signify the action to take for the resource.

Sunday, April 3, 2016

How to Convert Result of SELECT Command to Comma Separated String in SQL Server

Sometimes, you need the result of the SQL SELECT clause as a comma-separated String e.g. if you are outputting ids of white-listed products. By default, the SELECT command will print each row in one line and you get a column of names or ids. If you need a comma-separated String then you probably need to use a text editor like Notepad++, Edit Plus, or a tool like Microsoft Excel to convert that column of values into a big CSV String. I often use a text editor like edit plus to replace the \n to comma (,) to create such CSV string because it supports regular expression-based find and replaces operation.