Top 10 Oracle Interview Question and Answer - Database and SQL

These are some interview question and answer asked during my recent interview. Oracle interview questions are very important during any programming job interview. Interviewer always want to check how comfortable we are with any database either we go for Java developer position or C, C++  programmer position .So here I have discussed some basic question related with oracle database. Apart from these questions which is very specific to Oracle database you may find some general questions related to database fundamentals and SQL e.g. Difference between correlated and noncorrelated subquery in database  or truncate vs delete in SQL etc.

Step By Step guide to Read XML file in Java Using SAX Parser Example

Reading XML file in java using SAX Parser is little different than reading xml file in Java with DOM parser which we had discussed in last article of this series. This tutorial is can be useful for those who are new to the java world and got the requirement for read an xml file in java in their project or assignment, key feature of java is it provides built in class and object to handle everything which makes our task very easy. Basically this process of handling XML file is known as parsing means break down the whole string into small pieces using the special tokens.
Parsing can be done using two ways:

java.lang.UnsupportedClassVersionError: Bad version number in .class files Cause and Solution

How to fix Bad version number in .class file
"java.lang.UnsupportedClassVersionError: Bad version number in .class file" is a common error in Java programming language which comes when you try to run a Java class file. In our last article, we discussed that how to resolve Java.lang.UnSupportedClassVersionError and found that it comes when a major and minor version of the class is not supported by Java virtual machine or JRE running the program. Though "java.lang.UnsupportedClassVersionError: Bad version number in .class file" is little different than that of its manifestation and Cause.

Difference between DOM and SAX Parsers in Java

A difference between SAX and DOM Parser is very popular Java interview and often asked when interviewed on Java and XML. Both DOM and SAX parser are extensively used to read and parse XML file in java and have their own set of advantage and disadvantage which we will cover in this article. Though there is another way of reading XML file using XPath in Java which is the more selective approach like SQL statements people tend to stick with XML parsers. DOM Parser vs SAX parsers is also often viewed in terms of speed, memory consumption and their ability to process large XML files.

How to read and write Images in java using ImageIO Utility

Writing an Image file in Java is very common scenario and in this article we will see a new way to write images into file in Java. javax.imageio.ImageIO is a utility class which provides lots of utility method related to images processing in Java. Most common of them is reading form image file and writing images to file in java. You can write any of .jpg, .png, .bmp or .gif images to file in Java. Just like writing, reading is also seamless with ImageIO and you can read BufferedImage directly from URL.

How to Convert a Map to a List in Java Example

Map and List are two common data structures available in Java and in this article we will see how can we convert Map values or Map keys into List in Java. The primary difference between Map (HashMap, ConcurrentHashMap or TreeMap) and List is that Map holds two objects key and value while List just holds one object which itself is a value. Key in hashmap is just an addon to find values, so you can just pick the values from Map and create a List out of it. The map in Java allows duplicate value which is fine with List which also allows duplicates but Map doesn't allow duplicate key.

How to Compare Arrays in Java – Equals vs deepEquals Example

java.util.Arrays class provides equals() and deepEquals() method to compare two Arrays in Java. Both of these are overloaded method to compare primitive arrays e.g. int, long, float, double and Object arrays e.g. Arrays.equals(Object[] , Object[]). Arrays.equals() returns true if both Arrays which it is comparing are null If both arrays pointing to same Array Object or they must be of the same length and contains the same element in each index. In all other cases, it returns false. Arrays.equals() calls equals() method of each Object while comparing Object arrays.

How to append text into File in Java – FileWriter Example

Some times we need to append text into File in Java instead of creating new File. Thankfully Java File API is very rich and it provides several ways to append text into File in Java. Previously we have seen how to create file and directory in Java and how to read and write to text file in Java and in this Java IO tutorial we will see how to append text into file in Java. We are going to use standard FileWriter and  BufferedWriter approach to append text to File. One of the key point to remember while using FileWriter in Java is to initialize FileWriter to append text i.e. writing bytes at the end of File rather than writing on beginning of the File.

4 example to Iterate over HashMap, Hashtable or any Map in Java

There are multiple ways to iterate, traverse or loop through Map, HashMap, or TreeMap in Java and we all familiar with either all of those or some of those. But to my surprise, one of my friends was asked in his interview (he has more than 6 years of experience in Java programming) to write code for getting values from hashmap or TreeMap in Java in at least 4 ways. Just like me he also surprised by this question but written it. I don't know why exactly someone asks this kind of java interview question to a relatively senior java programmer. Though my closest guess is to verify that whether he is still hands-on with coding in java. Anyway, that gives me an idea to write this Java tutorial, and here are multiple ways to traverse, iterate or loop on a Map in Java, so remember this because you may also ask this question J.

Difference between equals method and "==" operator in Java - Interview Question

Both equals() and "==" operator in Java is used to compare objects to check equality but the main difference between equals method and  the == operator is that former is a method and later is an operator. Since Java doesn’t support operator overloading, == behaves identical for every object but equals() is method, which can be overridden in Java and logic to compare objects can be changed based upon business rules. Another notable difference between == and equals method is that former is used to compare both primitive and objects while later is only used for objects comparison.

What is final in Java? Final variable , Method and Class Example

Final in Java is very important keyword and can be applied to class, method, and variables in Java. In this java final tutorial we will see what is a final keyword in Java, what does it mean by making final variable, final method and final class in java and what are primary benefits of using final keywords in Java and finally some examples of final in Java. Final is often used along with static keyword in Java to make static final constant and you will see how final in Java can increase the performance of Java application.

How to add, subtract days, months, years, hours from Date and Time in Java

Adding days, hours, month or years to dates is a common task in Java. java.util.Calendar can be used to perform Date and Time arithmetic in Java. Calendar class not only provides date manipulation but it also support time manipulation i.e. you can add, subtract hours, minutes and seconds from current time. Calendar class automatically handles date transition or month transition for example if you ask date after 30 days it will return you date based on whether current month is 30 or 31 days long. Same is true in case of adding and subtracting years, Calendar takes care whether current or following year is a leap year or not.

Difference between Primary key vs Foreign key in table – SQL database tutorial

The main difference between Primary key and Foreign key in a table is that it’s the same column which behaves as primary key in the parent table and as a foreign key in a child table. For example in Customer and Order relationship, customer_id is the primary key in Customer table but a foreign key in Order table. By the way, what is a foreign key in a table and difference between Primary and Foreign key are some of the popular SQL interview questions, much like truncate vs delete in SQL or difference between correlated and noncorrelated subquery?

How to fix java.lang.classcastexception cannot be cast to in Java - cause and solution

As name suggests ClassCastException in Java comes when we try to type cast an object and object is not of the type we are trying to cast into. In fact ClassCastException in Java is one of most common exception in Java along with java.lang.OutOfMemoryError and ClassNotFoundException in Java before Generics was introduced in Java 5 to avoid frequent instances of java.lang.classcastexception cannot be cast to while working with Collection classes like ArrayList and HashMap, which were not type-safe before Java 5. Though we can minimize and avoid java.lang.ClassCastException in Java by using Generics and writing type-safe parameterized classes and method, its good to know real cause of ClassCastException and How to solve it.

Difference between Class and Object in Java and OOPS with Example

Class and Object are two most important concept of Object oriented programming language (OOPS)  e.g. Java. Main difference between a Class and an Object in Java is that class is a blueprint to create different objects of same type. This may looks simple to many of you but if you are beginner or just heard term Object Oriented Programming language it might not be that simple. I have met many students, beginners and programmers who don’t know difference between class and object and often used them interchangeably. Also Java API having classes like java.lang.Object and java.lang.Class also adds more confusion in beginners' mind. Both of them are totally different things, class and object in OOPS are concepts and applicable to all Object-oriented programming language e.g. C++ or Scala.

The real difference between Process and Thread in Java

One of the common questions from programming interviews is, what is the difference between a Thread and a Process? Well, the main difference between them is that a Process is a program that is executing some code and a thread is an independent path of execution in the process. A process can have more than one thread for doing independent task e.g. a thread for reading data from disk, a thread for processing that data, and another thread for sending that data over the network. This technique to improve throughput and better utilize CPU power is also known as multi-threading.

How to Attach Source Code in Eclipse to JAR Files for Debugging and Navigation With JDK Example

Attaching the source of any Jar in Eclipse e.g. JDK or open-source libraries like Spring framework is a good idea because it helps during debugging and code development. As a Java programmer at least you should attach the source of JDK in Eclipse IDE to find out more about JDK classes. Though Eclipse IDE is pretty good on code assist, sometimes You want to know what's going inside a library or a JDK method, rather than just reading the documentation. Interview questions like How HashMap works in Java or How substring cause memory leak can only be answered if you are familiar with the source code of these classes.  

How to Parse or Read XML File in Java >> XML Tutorial Example

How to parse xml file in Java or how to read xml file in java is one of common need of a Java Developer working with enterprise Java application which uses XML for data representation, messaging and data transfer. Java has good support to handle XML files and XML Documents and you can read XML File in Java, create or write to XML file in Java by using various XML parsers available. Reading XML file is little bit different than reading text or binary file in Java but it uses same concept of File class.

Recursion in Java With Example – Programming Techniques Tutorial

Recursion is one of the tough programming techniques to master. Many programmers working on both Java and other programming languages like C or C++ struggles to think recursively and figure out the recursive pattern in the problem statement, which makes it is one of the favorite topics of any programming interview. If you are new in Java or just started learning Java programming language and you are looking for some exercise to learn the concept of recursion than this tutorial is for you. In this programming tutorial, we will see a couple of examples of recursion in Java programs and some programming exercise which will help you to write recursive code in Java-like calculating Factorial, reversing String and printing Fibonacci series using recursion technique.

How to create thread safe Singleton in Java - Java Singleton Example

Thread safe Singleton means a Singleton class which returns exactly same instance even if exposed to multiple threads. Singleton in Java has been a classical design pattern like Factory method pattern or Decorator design pattern and has been used a lot even inside JDK like java.lang.Runtime is an example of Singleton class. Singleton pattern ensures that exactly one instance of class will remain in Java program at any time. In our last post 10 Interview questions on Singleton in Java we have discussed many different questions asked on Singleton pattern, One of them was writing Thread safe singleton in Java.

How to convert milliseconds to Date in Java - tutorial example

Do you want to convert milliseconds to Date in Java ? Actually java.util.Date is internally specified in milliseconds from epoch. So any date is number of millisecond passed since January 1, 1970, 00:00:00 GMT and Date provides constructor which can be used to create Date from milliseconds. Knowing the fact that Date is internally maintained in milliseconds allows you to store date in form of millisecond in Server or in your Class because that can be effectively expressed with a long value.

3 Examples to Print Array Elements/Values in Java - toString and deepToString from Arrays

Printing array values in Java or values of an array element in Java would have been much easier if  arrays are allowed to directly prints its values whenever used inside System.out.println() or format and printf method, Similar to various classes in Java do this by overriding toString() method. Despite being an object, array in Java doesn't print any meaningful representation of its content when passed to System.out.println() or any other print methods. If you are using array in method argument or any other a prominent place in code and actually interested in values of an array then you don't have much choice than for loop until Java 1.4.

How to check if a number is a palindrome or not in Java - Example

How to check if a number is a palindrome or not is a variant of popular String interview question how to check if a String is a palindrome or not. A number is said to be a palindrome if the number itself is equal to reverse of number e.g. 313 is a palindrome because the reverse of this number is also 313. On the other hand 123 is not a palindrome because the reverse of 123 is 321 which is not equal to 123, i.e. original number. In order to check if a number is a palindrome or not we can reuse the logic of How to reverse a number in Java.

Inner class and nested Static Class in Java with Example

Inner class and nested static class in Java both are classes declared inside another class, known as top level class in Java. In Java terminology, If you declare a nested class static, it will called nested static class in Java while non static nested class are simply referred as Inner Class. Inner classes are also a popular topic in Java interviews. One of the popular questions is the difference between inner class and nested static class , some time also refereed as difference between static and non static nested class in Java. One of the most important question related to nested classes are Where should you use nested class in Java?

How to Add, Modify and Drop Column With Default Value, NOT NULL Constraint – MySQL Database Example

How to add column in existing table with default value is another popular SQL interview question asked for Junior level programming job interviews. Though syntax of SQL query to add column with default value varies little bit from database to database, it always been performed using ALTER keyword of ANSI SQL. Adding column in existing table in MySQL database is rather easy and straight forward and we will see example of SQL query for MySQL database which adds a column with default value. You can also provide constraints like NULL or NOT NULL while adding new column in table.

Checked vs Unchecked Exception in Java Example

Checked and Unchecked Exception is two types of Exception exist in Java. Though there is no difference in functionality and you can very achieve same thing with either checked Exception or Unchecked Exception, there is some difference on exception handling part. In this Java tutorial we will see what is checked and Unchecked Exception in Java, Examples of Checked and Unchecked Exception and most importantly we will learn when to use Checked Exception and when to use Unchecked Exception in Java and lastly we will see difference between checked and unchecked exception to understand things better. By the way this article is second in my post on Exception along with difference between throw and throws in Java and improved Exception handling in Java 7 with Automatic resource management ARM and multi-catch block in JDK 7.

What is Type Casting in Java - Casting one Class to other class or interface Example

Type casting in Java is to cast one type, a class or interface, into another type i.e. another class or interface. Since Java is an Object oriented programming language and supports both Inheritance and Polymorphism, It’s easy that Super class reference variable is pointing to SubClass object but the catch here is that there is no way for Java compiler to know that a Superclass variable is pointing to SubClass object. Which means you can not call a method which is declared in the subclass. In order to do that, you first need to cast the Object back into its original type. This is called type casting in Java. You can type cast both primitive and reference type in Java. The concept of casting will be clearer when you will see an example of type casting in next section.

How to Create Auto Incremented Identity Column in SQL Server, MySQL, Sybase and Oracle?

Automatic incremented ID, Sequence or Identity columns are those columns in any table whose value is automatically incremented by database based upon predefined rule. Almost all databases e.g. Microsoft SQL Server, MySQL, Oracle or Sybase supports auto-incremented identity columns but in different ways like Oracle provides a SEQUENCE object which can be used to generate automatic numbers, Microsoft SQL Server up to 2008 version provides IDENTITY() functions for a similar purpose. Sybase also has IDENTITY function but little different than SQL Server and MySQL uses auto_incremented keyword to make any numeric column auto-incremented.

Observer design Pattern in Java with Real world code Example

Observer design pattern in Java is a fundamental core Java pattern where Observe watch for any change in state or property of Subject. For Example Company updates all its shareholders for any decision they make here Company is Subject and Shareholders are Observers, any change in policy of company and Company notifies all its Shareholders or Observer. This was simple real world explanation of Observer pattern. In this article we will in detail what is Observer Design pattern, what is benefit of Observer design Pattern, Example or Observer pattern in Java and few other points. Just like Decorator design Pattern and Factory Pattern in Java, Observer pattern is also used in JDK.

How to Parse or Convert String to long in Java - 4 Examples

How to convert a string to long in Java is one of those frequently asked questions by a beginner who has started learning Java programming language and not aware of how to convert from one data type to another. Converting String to long is similar to converting String to Integer in Java, in-fact if you know how to convert String to Integer than you can convert String to Long by following the same procedure. Though you need to remember few things while dealing with long and String first of all long is the primitive type which is wrapped by Long wrapper class and String is an Object in Java backed by character array.

How to fix org.apache.log4j.Logger Error in Java org.apache.log4j.Logger error says that an instance of org.apache.lo4j.Logger is not Serializable. This error comes when we use log4j for logging in Java and create Logger in a Serializable class e.g. any domain class or POJO which we want to store in HttpSession or want to serialize it. As we know from 10 Java Serialization interview question that, if you have a non serializable class as member in a Serializable class, it will throw Exception.

Look at the below code :

public class Customer implements Serializable{

private Logger logger =  Logger.getLogger(Customer.class)



How to redirect a page or URL using JavaScript and JQuery

Redirecting a web page means, taking the user to a new location. Many website uses redirects for many different reasons, e.g. Some websites redirect users from the old domain to new domain, some redirect from one page to another e.g. a more relevant page. If you are a Java programmer and worked previously with Servlet and JSP, then you might be familiar with SendRedirect and Forward methods, which are used to redirect users in web applications. Actually, there are two kinds of redirect, Server side redirect, and client-side redirect. In Server side redirect, server initiates redirection, while in a client-side redirect, client code does the redirection. Redirecting a web page using JavaScript and JQuery is a client-side redirection.

How to change Tomcat default port 8080

Tomcat default port is 8080 but many times other Java application also uses 8080 like any other web-server Resin or Jetty and starting tomcat may result in already in use: JVM_Bind 8080. In order to avoid this exception you can change default port of tomcat from 8080 to some other port e.g. 8081 or 8082. Though don't change to tomcat port which is likely to be used by tomcat itself e.g. 8443 is used by tomcat https port. Use port which is most likely to be free. In this tomcat tutorial we will see how to change default port 8080 for http protocol in tomcat and port 8443 port for https protocol in tomcat.

How to Create and Evaluate XPath Expression in Java - Tutorial and Example

You can use XPathExpression from javax.xml.xpath package to create and execute XPATH expression in Java.  Java API provides javax.xml.xpath  package, which contains classes like Xpath, XpathFactory to work with XPATH and XML documents. By the way this is third article on Xpath, In last couple of tutorials e.g. XPATH examples to select values using attributes and my XPATH notes for Java programmer, we have seen basics of Xpath expression from XML and Java point of view.  Anyone who has work with XML technologies in Java knows importance of XPATH, it is one the most useful technology to retrieve selected data from XML files.

VirtualBox - /sbin/mount.vboxsf: mounting failed with the error: Protocol error [Solution]

I use Oracle's virtual machine, Virtualbox to run the Linux operating system from my Windows machine. It's the most simple way to have two operating system in your laptop or PC. Since I run most of Java program in Linux, VirtualBox gives me a nice interface to run UNIX commands right from Windows box. This blog post is about the mounting of shared folder failed error in Oracle's Virtualbox VM. It was working fine day before yesterday and now, after I restarted my virtual box and tried to mount my shared folder, I was greeted by this error: "/sbin/mount.vboxsf: mounting failed with the error: Protocol error". I was using the following command to mount my shared folder on VirtualBox:
$ mount -t vboxsf mountfolder /home/devInHost/mountfolder

I was running Oracle's VirtualBox 4.1 version with the guest operating system as RedHat Linux and host OS as Windows 8.

How to get current date, month, year and day of week in Java program

Here is quick Java tip to get the current date, month, year, and day of week from Java program. Java provides a rich Date and Time API though having thread-safety issue but its rich in function and if used locally can give you all the date and time information which you need for your enterprise Java application. In last Java tutorial on Date and Time API we have seen how to get current date and time from different timezone using DateFormat and SimpleDateFormat classes and in this post, we will get some more details like a current month, year, day of the week, etc by using java.util.Calendar class.  Just keep in mind that the Calendar instance should not be shared between multiple threads.

How to Create and Modify Properties File Form Java Program in Text and XML Format

Though most of the time we create and modify properties file using text editor like notepad, word-pad or edit-plus, It’s also possible to create and edit properties file from Java program., which is used to configure Log4J based logging in Java and which is used to specify configuration parameters for database connectivity using JDBC are two most common example of property file in Java. Though I have not found any real situation where I need to create properties file using Java program but it’s always good to know about facilities available in Java API. In last Java tutorial on Properties we have seen how to read values from properties file on both text and XML format and in this the article we will see how to create properties file on both text and XML format.

How to Count Occurrences of a Character in String - Java Programming Exercise Example

Write a program to count the number of occurrences of a character in String is one of the common programming interview questions not just in Java but also in other programming languages like C or C++.  As String in a very popular topic on programming interviews and there are a lot of good programming exercise on String like "count number of vowels or consonants in String", "count number of characters in String", How to reverse String in Java using recursion or without using StringBuffer, etc, it becomes extremely important to have a solid knowledge of String in Java or any other programming language. Though, this question is mostly used to test the candidate's coding ability i.e. whether he can convert logic to code or not.

How to read input from command line in Java using Scanner

Java 5 introduced a nice utility called java.util.Scanner is capable of reading input from the command line in Java. Using Scanner is a nice and clean way of retrieving user input from console or command line. The scanner can accept InputStream, Reader or simply path of the file from where to read input. In order to read from the command line, we can pass into Scanner's constructor as a source of input. The scanner offers several benefits over the classical BufferedReader approach, here are some of the benefits of using java.util.Scanner for reading input from the command line in Java:

Difference between Method Overloading and Overriding in Java?

Method Overloading vs Method Overriding
Though the name of the method remains same in the case of both method overloading and overriding, main difference comes from the fact that method overloading is resolved during compile time, while method overriding is resolved at runtime. Also rules of overriding or overloading a method are different in Java. For example, a private, static and final method cannot be overriding in Java but you can still overload them. For overriding both name and signature of the method must remain same, but in for overloading method, the signature must be different. Last but not the least difference between them is that call to overloaded methods are resolved using static binding while the call to overridden method is resolved using dynamic binding in Java.

How to remove duplicates elements from ArrayList in Java

You can remove duplicates or repeated elements from ArrayList in Java by converting ArrayList into HashSet in Java. but before doing that just keep in mind that Set doesn't preserver insertion order which is guaranteed by List, in fact that’s the main difference between List and Set in Java. So when you convert ArrayList to HashSet all duplicates elements will be removed but insertion order will be lost. Let’s see this in action by writing a Java program to remove duplicates from ArrayList in Java. In this Java collection tutorial, we will see both approaches of deleting duplicates from ArrayList e.g using Hashset and LinkedHashSet and compare the order of elements in final ArrayList which contains no duplicates.

10 points about instanceof operator in Java with example

The instanceof operator in Java is used to check if an object belongs to a particular type or not at runtime. It's also a built-in keyword in Java programming language and mostly used to avoid ClassCastException in Java. It is used as a safety-check before casting any object into a certain type. This operator has a form of object instanceof Type and returns true if the object satisfies IS-A relationship with the Type i.e. object is an instance of class Type or object is the instance of a class which extends Type or object is an instance of a class which implements interface Type.

How to print Floyd's Triangle in Java with Example

There are lots of programming exercises in Java, which involves printing a particular pattern in console, one of them is printing Floyd triangle in the console. In Floyd triangle, there are n integers in the nth row and a total of (n(n+1))/2 integers in n rows. This is one of the most simple patterns to print but helpful in learning how to create other more complex patterns. The key to develop patterns is using nested loops and methods like System.out.print() and println() appropriately. Actually, pattern-based programming tasks are originally designed to master loops in programming.

XPath Tutorial - How to select elements in XPATH based on attribute and element value example

In this XPATH tutorial we will see example of selecting elements based upon its value or attribute value. We will see how to select between two elements based upon value of its child elements or based upon value of its attribute. XPATH is an important concept to understand if you are working with XML files. Most of Back-office platform relies on XML files for transporting data from one system to other and if you are working on any back-office or middle office system in Java or .NET, its important to know about XPATH and be able to use XPATH to select data from XML. Some time back I have shared my XPATH notes for Java programmer and this example shows true power of XPATH as how convenient its to made selective decision.

Constructor Chaining in Java - Calling one constructor from another using this and super

Constructor Chaining in Java
In Java, you can call one constructor from another and it’s known as constructor chaining in Java. Don’t confuse between constructor overloading and constructor chaining, former is just a way to declare more than one constructor in Java. this and the super keyword is used to call one constructor from other in Java. this() can be used to call another constructor of the same class while super() can be used to call a constructor from superclass in Java. Just keep in mind that this() in reality calls the no-argument constructor of the same class while this(2) calls another constructor of the same class which accepts one integer parameter.

How to Escape String Literal in Java Using Eclipse IDE

Whenever you paste String in Eclipse which contains escape characters,  to store in a String variable or just as String literal it will ask to manually escape special characters like single quotes, double quotes, forward slash, etc. This problem is more prominent when you are pasting a large chunk of data which contains escape characters like a whole HTML or XML file,  which contains lots of single quotes e.g. ‘’ and double quotes “” along with forwarding slash on closing tags. It’s very hard to manually escape all those characters and it's pretty annoying as well. While writing JUnit test for XML documents, parsing, and processing I prefer to have the whole XML file as String in the Unit test, which pointed me to look for that feature in Eclipse.

Invalid initial and maximum heap size in JVM - How to fix

I was getting "Invalid initial heap size: -Xms=1024M" while starting JVM and even after changing maximum heap size from 1024 to 512M it keeps crashing by telling "Invalid initial heap size: -Xms=512m , Could not create the Java virtual machine". I check almost everything starting from checking how much physical memory my machine has to any typo in JVM parameters, only to find out that instead of M, I had put MB there. Java accepts both small case and the capital case for Kilo, Mega, and Gigs. you can use m or M, g or G, etc but never used MB, GB, or KB.  Similar problem can occur with maximum heap size specified by -Xmx. Also from Java 6 update 18, there is a change in default heap size in JVM.  

Financial Information Exchange (FIX) Protocol Interview Questions Answers

Financial Information Exchange (FIX) Protocol Interview Questions and Answers
Some more Fix protocol interview question , I will put answer along when I'll get some time for now just questions :) 

Now I have updated it with answer, Please let me know if you have any doubt, or you have other questions, you can also contribute by any question asked during any FINANCIAL INFORMATION EXCHANGE (FIX)  protocol interview.

FIX Protocol Interview Question and Answers

What do you mean by Warrant?
Warrant is a financial product which gives right to holder to Buy or Sell underlying financial security, its similar to option with some differences e.g. Warrants are normally issued by banks while options are primarily traded in exchange. Address already in use: JVM_Bind:8080 Solution Address already in use: JVM_Bind is a common exception in Java with application trying to connect on a particular port and some other processes either Java or non Java is already connected on that port. You can get "Address already in use: JVM_Bind" error while doing remote debugging in Java in Eclipse, when Eclipse trying to connect to remote Java application when you are starting tomcat and another instance of tomcat is listening on port 8080 you will get Address already in use: JVM_Bind:8080.

Why main method is public static in Java

Main method in Java is the first programming method a Java programmer knows when he starts learning Java programming language.have you ever thought about why main method in Java is public, static and void, of-course Yes, since most of us first learn C and C++ than we move to Java in our programming path we familiar with main method but in Java main method is slightly different it doesn't return any value like in C it returns int, main method is public static and void Why? In this post we will try to find answer to these questions and have an idea of one of the most popular questions in Java why main method is declared Static.

How to sort HashMap by key and value in Java - Hashtable, Map Example Tutorial

Sorting HashMap in Java is not as easy as it sounds because unfortunately Java API doesn't provide any utility method to sort HashMap based on keys and values. Sorting HashMap is not like sorting ArrayList or sorting Arrays in Java. If you are wondering why we can not use Collections.sort() method than for your information it only accepts List<E>, which leaves us to write our own utility methods to sort Map in Java. This is true for all types of Map like Hashtable, HashMap, and LinkedHashMap. TreeMap is an already a sorted Map so we don't need to sort it again. Why we need to sort HashMap in Java, Why can't we use TreeMap in place of HashMap is the question appears in most Java programmer's mind when they asked to sort HashMap in Java.

Does Java Pass by Value or Pass by Reference - Interview Question

Does Java is pass by value or pass by reference is one of the tricky Java question mostly asked on fresher level interviews. Before debating whether Java is pass by value or pass by reference lets first clear what is pass by value and what is pass by reference. This question has its origin on C and C++ where you can pass function parameter either value or memory address, where value is stored (pointer). As per Java specification everything in Java is pass by value whether its primitive value or objects and it does make sense because Java doesn't support pointers or pointer arithmetic, Similarly multiple inheritance and operator overloading is also not supported in Java.

Common issue on financial information exchange (FIX) Connectivity

FIX Protocol Session Connectivity
Hi guys, in this post I would like to share my experience with financial information exchange (FIX) Connections which is essential to setup FIX connectivity for trading purposes. Financial information exchange (FIX) Connections used in both Client Connectivity and Exchange connectivity space (in case exchange supports financial information exchange (FIX) Protocol or you are connecting to any broker via FINANCIAL INFORMATION EXCHANGE (FIX) Protocol).

What is load-on-startup servlet element in web.xml with Example?

load-on-startup is an element that appears inside <servlet> tag in web.xml.4 years back load-on-startup was a very popular servlet interview question because not many Java J2EE developer was familiar with this element and how load-on-startup works inside a servlet container like tomcat or WebSphere. In this J2EE Tutorial, we will see what is a load on startup, how to use load-on-startup element, and what are different values we can configure for loadOnStartup inside web.xml.

Inversion of Control and Dependency Injection design pattern with real world Example - Spring tutorial

Inversion of Control and Dependency Injection is a core design pattern of Spring framework. IOC and DI design pattern is also a popular design pattern interview question in Java. As the name suggest Inversion of control pattern Inverts responsibility of managing the life cycle of the object e.g. creating an object, setting their dependency etc from application to a framework, which makes writing Java application even more easy. The programmer often confused between IOC and DI, well both words used interchangeably in Java world but Inversion of Control is a more general concept and Dependency Injection is a concrete design pattern.

Java Error : 'javac' is not recognized as an internal or external command

So you are trying to compile your Java source file and getting "'javac' is not recognized as an internal or external command". If this is your first Java program or HelloWorld than I suggest going through How to compile and run HelloWorld in Java because that explains what do you need before you compile and run any Java program. If you have crossed that level and knows about How to set PATH in Java then there is something wrong while setting PATH in Java. Anyway let's see when do you get this error and from where does 'javac' is not recognized as an internal or external command comes.

5 Example of kill command in UNIX and Linux

Kill command in UNIX and Linux is normally used to kill a suspended or hanging process or process group. Though kill is mainly associated with kill operation its merely a signal transporter and can send specified signals to specified processes in UNIX or UNIX like systems e.g. Linux, Solaris, or FreeBSD. Like in windows when we see a particular process hung the system we go to the task manager find the process and kill it, similarly, in UNIX and Linux we first find the process ID (PID) of the offending process and then kill it.

java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver - cause and solution

java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver Exception comes when you try to connect the Oracle database from Java program and Oracle driver is not available in Classpath. We have already seen How to connect Oracle database from Java program and found that, In order to connect to Oracle database, we load and register driver using Class.forName("oracle.jdbc.driver.OracleDriver") and this code loads a class at runtime using Reflection which throws ClassNotFoundException if the class in question e.g. "oracle.jdbc.driver.OracleDriver" is not found.

How to configure Log4j in Java program without XML or Properties File

Sometime configuring Log4j using XML or properties file looks annoying, especially if your program not able to find them because of some classpath issues, wouldn't it be nice if you can configure and use Log4j without using any configuration file e.g. XML or properties. Well, Log4j people has thought about it and they provide a BasicConfigurator class to configure log4j programmatically, thought this is not as rich as there XML and properties file version is, but it's really handy for quickly incorporating Log4j in your Java program.

What is Constructor in Java with Example – Constructor Chaining and Overloading

What is constructor in Java
Constructor in Java is block of code which is executed at the time of Object creation. But other than getting called, Constructor is entirely different than methods and has some specific properties like name of constructor must be same as name of Class. Constructor also can not have any return type, constructor’s are automatically chained by using this keyword and super. Since Constructor is used to create object, object initialization code is normally hosted in Constructor. Similar to method you can also overload constructor in Java. In this Java tutorial we will some important points about constructor in Java which is worth remembering for any Java programmer.

Java TreeMap Tutorial: 15 Example of TreeMap in Java

TreeMap in Java is a SortedMap and it maintains Sorting order when you insert object on it. You can specify Sorting order while Creating TreeMap by providing an explicit Comparator to TreeMap. Basically you can create TreeMap in Java by different ways, a TreeMap with natural sorting order, and TreeMap with custom Sorting Order by providing Comparator, Copying Sorting order from other SortedMap etc. TreeMap has specific constructor for these conditions. We will see these in section of creating instance of TreeMap in Java. 

How to comment uncomment single line and block of code in Java - Eclipse Tips Tricks

Knowing Eclipse shortcut to comment and uncomment single line or block of code can save you a lot of time while working in Eclipse. In fact I highly recommend every Java programmer to go through these top 30 Eclipse shortcut and  10 java debugging tips in Eclipse for improved productivity.  If you are Java programmer, coding in Eclipse and want to comment and uncomment single line or block of code quickly you can either use ctrl + / to comment a single line and subsequently uncomment a commented line. If you want to comment a block of code or a complete method, you have two option you can either line comment (//) all those selected lines or block comment (/* */) those lines.

9 Things about Null in Java

Java and null are uniquely bonded. There is hardly a Java programmer, who is not troubled by null pointer exception, it is the most infamous fact about. Even inventor of null concept has called it his billion dollar mistake, then why Java kept it? Null was there from long time and I believe Java designer knows that null creates more problem than it solves, but still they went with it. It surprise me even more because Java's design philosophy was to simplify things, that's why they didn't bothered with pointers, operator overloading and multiple inheritance of implementation, they why null. Well I really don't know the answer of that question, what I know is that, doesn't matter how much null is criticized by Java developers and open source community, we have to live with that.

How to split a comma separated String in Java? Regular Expression Example

You can use the String.split() function or StringTokenizer class to split a comma-separated String in Java. Since splitting a String is a very common functionality, Java designers have provided a couple of split() method on java.lang.String class itself. These split() function takes a regular expression and split the String accordingly. In order to parse a comma-delimited String, you can just provide a "," as a delimiter and it will return an array of String containing individual values. The split() function internally uses Java's regular expression API (java.util.regex) to do its job.

Union and Intersection of two Set in Java - Google Guava Example

Google Guava is an open source library which provides lots of useful utility to Java programmer,  one of them is easy way to find intersection and union of two Set in Java. You might have used Google Guava for other functionality e.g. for overriding toString in easy way or Immutable Collection provided by Guava library. Along with Apache commons and Spring, Google Guava is a library you definitely want to include in your Project. Guava provides couple of static method to operate on Set in Java on package There are two methods called intersection() and union() which provides intersection and union of two Sets in Java. In this example we have used HashSet as Set implementation but it will work with any Set implementation e.g. TreeSet or LinkedHashSet.

How to parse String to Enum in Java | Convert Enum to String with Example

Converting Enum into String and parsing String to Enum in Java is becoming a common task with growing use of Enum. Enum is very versatile in Java and preferred the choice to represent bounded data and since is almost used everywhere to carry literal value it's important to know how to convert Enum to String in Java. In this article, we will see both first converting Strings to Enum in Java and then Change an Enum to String in Java with Example. I thought about this Enum tutorial when I wrote 10 Examples of Enum in Java. I missed String to Enum conversion and one of reader pointed out that. So here we have now.

How ClassLoader Works in Java

Java class loaders are used to load classes at runtime. ClassLoader in Java works on three principles: delegation, visibility, and uniqueness. Delegation principle forward request of class loading to parent class loader and only loads the class if the parent is not able to find or load the class. Visibility principle allows child class loader to see all the classes loaded by parent ClassLoader, but parent class loader can not see classes loaded by a child. Uniqueness principle allows one to load a class exactly once, which is basically achieved by delegation and ensures that child ClassLoader doesn't reload the class already loaded by a parent. Correct understanding of class loader is a must to resolve issues like NoClassDefFoundError in Java and java.lang.ClassNotFoundException, which are related to class loading.

Top 5 FIX Protocol Data Dictionaries and Online FIX References

While you work on FIX Protocol you need a handy FIX Data dictionaries or what we called fixionary in order to refer for exact details related to the particular message type, particular fix tag and what does a particular value of tag means. Without FIX data dictionary or fix wiki it’s very hard to work especially when you are dealing with different fix protocol versions like FIX 4.0, FIX 4.1, FIX 4.2 and FIX 4.4. In this FIX Protocol article, we will explore some of the free available fixionaries or fix protocol reference guides. FIX data dictionary is a must have development tool for FIX protocol developers.

Top 10 JDBC Interview questions answers for Java programmer

JDBC Interview Question and Answer
JDBC Questions are an integral part of any Java interview,  I have not seen any Java Interview which is completed without asking the single JDBC Interview question, there is always at least one or two questions from JDBC API. Some of the popular questions like Why you should use PreparedStatement in Java,  Difference between PreparedStatement and CallableStatement in Java and few questions is related to improving the performance of the JDBC layer by applying some JDBC performance tips. In this article, I have summarized a few frequently asked questions in JDBC, they range from easy to difficult and beginner to advanced.

What is Object in Java Programming and OOP - Example Tutorial

Object in Java
Object in Java programming language or any other Object oriented programming language like C++ are core of OOPS concept and that's why the name. Class and Object along with Inheritance, Polymorphism, Abstraction and Encapsulation forms basis of any Object oriented programming language e.g. Java. Objects are instances of Class, Class define blue prints and Objects are thing which are created based upon that blueprint. Object are also known as instance in Java, e.g. When we say an instance of String class, we actually mean an Object of String class. Object has state and behavior in Java. State is represented using instance variable and static variable in Java class and behaviors are implemented using methods in Java.

How to read and write in text file in Java

Java has excellent support for reading from file and writing to file in Java. In last post we have seen how to create file and directory in Java and now we will see how to read content from file in java and how we will write text into file in Java. File provides persistent solution to Java developer; in almost every Java application you need to store some of the data in persistent may be its user configuration, system configuration or related to state of application but without persistence no enterprise Java application can buildup. Normally Database is preferred choice for storing data persistently but in high frequency trading one doesn’t have liberty to afford network latency to travel database and latency introduced by database itself.

How to do static import in Eclipse - Java

Do you know what is a shortcut to doing static import in Eclipse? Well, I didn't know before, but today I come to know that shortcut Ctrl+Shift+M (Source > Add Import) can not only be used to add missing imports but It can also help with static import in Java program.  Suppose you are using lots of static variables from a utility class e.g. TimeUnit by referring them with the class name, just like we refer static variable. In Eclipse IDE, you can select the whole reference variable and press Ctrl+Shift+M and it will automatically import that static element using static import in Java.

BlockingQueue in Java – ArrayBlockingQueue vs LinkedBlockingQueue Example program Tutorial

BlockingQueue in Java is added in Java 1.5 along with various other concurrent Utility classes like ConcurrentHashMap, Counting Semaphore, CopyOnWriteArrrayList etc. BlockingQueue is a unique collection type which not only store elements but also supports flow control by introducing blocking if either BlockingQueue is full or empty. take() method of BlockingQueue will block if Queue is empty and put() method of BlockingQueue will block if Queue is full. This property makes BlockingQueue an ideal choice for implementing Producer consumer design pattern where one thread insert element into BlockingQueue and other thread consumes it.

How to deal with Java.rmi.MarshalException: CORBA MARSHAL in Java

Java has some mysterious RMI exception one of them is java.rmi.MarshalException: CORBA MARSHAL, which was bothering me from last couple of days while working. I thought to put this solution post similar to my earlier post How to solve OutofMEmroyError in Java and Fixing ClassNotFoundException in Java. RMI is still used in many places and many times it create too much problem and chew-up your lot of time to find exact cause and solution.

FIX protocol and fix messaging interview questions

FIX (financial information exchange) protocol is the global protocol used for Electronic trading of different asset classes e.g Equity, Fixed Income FX (foreign exchange) , Derivatives Futures and Options and its knowledge is essential to understand Electronic trading and FIX messages. I have listed some of the very common but informative questions asked in fix protocol interview question, this list is by no means complete and only contains questions on top of my mind, I would encourage reader to post any question they have been asked and I will include on this list, Please feel free to ask any other question related to FIX (financial information exchange) protocol I would be happy to answer those. FIX messaging is a term used to describe communication using FIX protocol.