If you are a C++ Programmer, now learning Java then you will find lot of similarity between two of the most popular object oriented programming languages e.g. both support Abstraction, Encapsulation, Class, Object and other OOP concepts. But, they are some subtle differences as well, e.g. both Java and C++ have constructor and they work the same way in Java as they do in C++, but the way they are called is different. For example, In Java, a constructor must be called by using new() operator, there is no other way to explicitly call the constructor while creating object, but in C++ you can do it without new operator. This is a good interview questions for programmers who knows both Java and C++. I know, switching context between C++ and Java is not easy, especially during interview but that's also perfect way to test how much experience candidate has. An experience C++ programmer which has worked in Java for couple of years should know the different on top of their head. BTW, if you are from C++ background and looking for a good book to learn Java then check out Core Java, Volume 1 by Cay S. Horstmann. Cay has taken care to put C++ perspective of things when introducing new concepts in Java. So, you will find comparison of Generics in Java with templates in C++, which helps to understand the concept quickly.
Wednesday, September 2, 2015
Monday, August 31, 2015
Though both SOAP and RESTful web services allows a client to query server for some information, but the way they are implemented and used is quite different. Main difference between SOAP and REST is that former provides an standard of communication between client, server and other parties and has restricted set of rules and format, while REST leverages 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, its easy to understand and correlated how RESTful webservice 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 right way to call them.
Saturday, August 29, 2015
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 name of your class which has incompatible version.