Though both SOAP and RESTful web services allow a client to query the server for some information, but the way they are implemented and used is quite different. The main difference between SOAP and REST is that former provides a standard of communication between client, server and other parties and has restricted a set of rules and format, while REST leverages the ubiquity of HTTP protocol, in both client and servers, to allow them to communicate with each other regardless of their implementation. In short, getting data from a RESTful web service requires less headache then getting data from a SOAP web service. Since everybody is familiar with HTTP requests like GET or POST, it's easy to understand and correlated how RESTful web services are working and which URL of REST web service provides what kind of information. In SOAP, you need to understand lengthy WSDL document to find out right methods and the right way to call them.
Unsupported major.minor version 51.0 error comes when you run a class file created using Java 1.7 (major version 51.0) into a lower JRE version e.g. JRE 6, 5 or 4. There are two ways to solve this problem, first make sure you run your Java program in same or higher version of JRE, on which it has compiled, and second use cross-compilation option to create a class file compatible to a lower JRE. You can use javac -target option to create a class file for all JRE up-to-the JDK version you are using for compilation. For example, if you are compiling your Java source file into JDK 1.7 then you can create class files to run on JDK 1.1, 1.2, 1.3, 1.4 , 1.5 and 1.6 version, but you cannot create class files compatible with Java 1.8. When you compile a Java source file, it creates a class file and add the class file version into it. In order to run that class file, your JRE must understand that version. When JRE or JVM which is running the class doesn't able to understand the class file version they throw java.lang.UnsupportedClassVersionError: XXX : Unsupported major.minor version 51.0 error, where XXX is the name of your class which has an incompatible version.
Labels: error and exception
Factorial of numbers greater than or equal to 13 cannot be found using primitive int data type as shown in our earlier factorial solution due to overflow. These factorials are too large to fit in an int variable, whose maximum value is just 2147483647 (2^31 -1). Even if we use the long data type, factorials greater than or equal to 21 will generate an overflow. To find the factorial of anything above 21, you need to use the BigInteger class from java.math package. As the name suggests, BigInteger class is designed to hold really large integer value, something which is even bigger than the maximum value of long primitive e.g. 2^63 -1 or 9223372036854775807L. You also need to change the way we calculate factorial for a smaller number. You can not use recursion to calculate factorial of a larger number instead we need to use for loop for that.
Labels: Coding Interview Question
The java.util.Map is one of the most important interfaces from Java Collection Framework. It provides hash table data structure functionality by its implementations like HashMap, Hashtable, LinkedHashMap and a little bit of sorting with the TreeMap. So if you are looking to store key-value pairs in Java program, you have a wide range of choices available depending upon your requirement. The main difference between LinkedHashMap, TreeMap and HashMap comes in their internal implementation and specific features, which makes them useful in certain scenarios. For example, the HashMap is a general purpose Map (hash table data structure), which should be used whenever you need a hashing-based data structure for storing your mappings (key-value pairs).
StackOverFlow is great place to look for help, learn and participate, but it's also a great place to taste some real entertainment, contributed by programmers from all over the world. Though, due to strict policies of stackoverflow.com, most of entertaining post either are either gets closed or deleted, some of them remained to entertain programming community. Being a regular reader of StackOverFlow from long time, I have found couple of threads which are truly amazing, and has lot's of funny and entertaining content. Here I am going to share 5 of my favorite StackOverFlow posts, which I suggest you to read, if you get bored or you have some time to kill. By the way, don't forget to leave comments and let us know which is your favorite funny and entertaining threads in StackOverFlow.
For a change, this article is not for candidates who are preparing for interviews, but for those programmers who are responsible for taking interviews. At some point in your career as a programmer, you will have the responsibility to hire developers for your company. This is a big responsibility and your ability to select right candidate will directly affect your company's future. This is more visible in small companies than the larger organization where a pool of interviewer exists. In a start-up, if you are a technical lead and responsible for hiring, it's a tough job. You have to hire right candidate which fits in companies culture and competent enough to do the job they were hired for. To be frank, conducting interviews is as hard as giving interviews.
How to find all permutation of a String using recursion is one of the tricky coding questions from Programming job interviews. I have first seen this question in my college exam when we were asked to code the solution using C or C++ language. Since then I have seen this question many times at various written tests and Java interviews for a junior developer position. It does not only serve as a good question to check whether the candidate understands recursion but also its one of the better Java programming exercise for beginners. Typically, you will be asked to write a method, which accepts a String and print all permutations or may return all permutations in a List for a junior developer position. Depending upon the company you are going for an interview, they may ask you to code on IDE like Eclipse or NetBeans, or simply write code in plain paper, so be prepared for both.
Labels: Coding Interview Question
for loop has come a long way in Java 8 with new forEach() method in java.util.stream.Stream class. In this article, we will take a look at the journey of for loop in different versions of Java programming language. for loop is there from the very beginning of Java i.e. JDK 1.0. Almost all Java programmers have used the classical for() loop, as it is also an essential programming construct, I guess just next to if-else, but when the foreach loop or as some people call it enhanced for loop was introduced in JDK 1.5, everything changed from looping over Collection and array perspective. Yesterday's popular looping construct become old and ugly and more elegant solution took over. It was shorter, cleaner and less error prone, what else you need at that time.
Labels: Java 8
ByteBuffer is one of the important class of Java NIO API. It was introduced in java.nio package on JDK 1.4, it not only allows you to operate on heap byte arrays but also with direct memory, which resides outside the JVM. There are mainly three types f ByteBuffer, Direct, Non-Direct and mapped byte buffers. You can create both direct and non-direct buffers using java.nio.ByteBuffer class, while MappedByteBuffer is a subclass of ByteBuffer, which is created by FileChannel.map() method, to operate on memory mapped file. The main difference between direct and non-direct byte buffers are there memory location, non-direct byte buffers are just a wrapper around byte array and they reside in Java Heap memory while direct byte buffer is outside of JVM and memory is not allocated from the heap.
If you remember, I have updated to Windows 10 yesterday and blog about the problem I was facing with respect to clarity of text and blurriness on Chrome and Firefox browser e.g. text was turned white to some places and it wasn't pleasant working in the browser. There were few other issues, which prompted me to revert back to Windows 8.1 update, which was the version I was running before upgrading to Windows 10. Though Windows 10 has lots of good feature in terms of improved search, security and start menu, I didn't adjust it well. Since I don't have time to play around different visual settings and other things, I decided to roll back to Windows 8 version.
Labels: Windows 10
Today morning, I updated My HP Laptop to Windows 10. The first impression was great, crystal clear images, better wallpaper, better themes, better welcome screen and improved start menu and task bar at the right-hand corner. But when I open Chrome and Firefox the text look faded, more bright and contrast was not perfect. Since I had not changed anything, I suspect this is the Windows 10 default settings which are causing the problem. I knew it before because I had also faced similar issues when I was moved from Windows XP to Windows 8 and then Windows 8.1 update. If you are facing the same problem where your Chrome, Firefox are not looking clear, instead looking blurry and faded then you need to adjust your Laptop's screen brightness, contrast, and gamma.
Labels: Windows 10