Difference between include() and forward() methods of RequestDispatcher in Servlert

What is the difference between include and forward methods of RequestDispatcher interface is one of the frequently asked Servlet questions from Java EE interviews and we'll see how you can answer this question on your interview. You get the RequestDispatcher reference either from ServletContext or ServletRequest interface and even though both include() and forward() method allow a Servlet to interact with another servlet, the main difference between include() and forward is that the include() method is used to load the contents of the specified resource (could be a Servlet, JSP, or static resource like HTML files) directly into the Servlet's response, as if it is part of the calling Servlet. 

Base64 Encoding and Decoding Examples in Java 8 and Before

Though, there are a couple of ways to Base64 encode a String in Java e.g. by using Java 6's javax.xml.bind.DatatypeConverter#printBase64Binary(byte[]) or by using Apache Commons Codec's Base64.encodeBase64(byte[) and Base64.decodeBase64(byte[])as shown here, or the infamous Sun's internal base64 encoder and decoder, sun.misc.BASE64Encoder().encode() and sun.misc.BASE64Decoder().decode(), there was no standard way in JDK API itself. That was one of the few missing item (another one is about joining string) which is addressed in Java 8.

How Java achieves platform independence? Answer

Java is a platform-independent language How?
Java a programming language provides platform independence, what does it mean? It means the same Java program can be run on any platform or operating system like Windows, Linux or Solaris without any change. This is a great benefit for someone coming from a platform-dependent programming language like C or C++ whose code needs to be ported for every single platform because they use native libraries, which differ in every platform. Now the question comes how Java achieves platform independence, what makes Java programs running on every platform without any change

10 Difference between Struts 1.x and Struts 2.x framework in Java

What is the difference between Struts 1 and Struts 2 is one of the popular Struts interview questions from Java JEE interviews? If you have mentioned Struts in your CV then you can expect this question on the telephonic or face-to-face round of interviews. Struts 1.x was a very popular MVC framework for Java web applications in the last decade, but when Spring MVC comes it lost a lot of its sheen. Spring framework's dependency injection and inversion of control feature, along with several other template-based features makes it the de-facto framework for developing Java applications. 

When You should Not use Microservice Architecture? (Answer)

 Hello guys, recently while giving interview in one of the big US based Investment bank I was asked about, what are the scenarios when you shouldn't be using Microservices architecture? When I hear this question I was big surprised not because I didn't know the answer but because most of the people ask about using Microservice architecture and this was the first time I am hearing otherwise. To be honest, it's a good question because most of the candidate will prepare about benefirst about Microservice architecture and they may not know when it's not appropriate to use it. Since I have worked in low latency high frequency application, I knew that multiple process means more latency so clearly a Microservices is a big no if you are working on a high frequency low latency application. In those cases you want to do all your calculations inside a single thread or process without even swapping memory to avoid delay. Hence the first answer to this question was, you shouldn't be using Microservice in a low latency application. 

10 Examples of Comparator, Comparable, and Sorting in Java 8

The Comparator class is used to provide code or logic for comparing objects in Java, while sorting a list of objects or a collection of objects. It's close cousin of Comparable which provides natural order sorting e.g. ascending and descending orders for numbers like int, short, long or float, and lexicographic order for String i.e. the order on which words are arranged in dictionaries. The Comparators are used while sorting arrays, lists and collections. You pass logic to compare objects and sorting methods like Collections.sort() use that logic to compare elements until they are arranged in sorted order. 

Difference between static and instance member variables in Java? Answer Example

Hello Java Programmers, In the last article, I had explained some key differences between static and nonstatic methods in Java, and in this part, I'll explain the difference between static and nonstatic member variables in Java. The concept of static remains the same, that doesn't change with method or member variables but there are still some subtle details, which every Java programmer should know and understand. As with static methods, a static member variable belongs to a class and a non-static member variable belongs to an instance. 

23 Java Static Class, Methods and Variables Interview Questions with Answers

The static keyword is one of the essential keyword in Java which represent the concept of static in programming. When you make something static, it is averse to change i.e. it is not dynamic and that is true for static variable, methods and class in Java. When you make a member variable static in Java, JVM assumes that the value of that variable will not change between instance and remain same for all objects of that class, hence it is also referred as class variable. Same is true for static methods, which is bonded during compile time because JVM assumes that their definition will not change because they are static and not virtual.

Top 20 Abstract Class and Method Interview Questions and Answers in Java

Both abstract class and abstract methods are very important concepts in core Java and every Java developer should have good understanding of what they are, when to use them and how to use them. They are also very popular on core Java job interviews as well as on Oracle Java certifications e.g. OCAJP or OCPJP. You will often find a lot of code based questions testing essential core Java concepts based upon abstract class and methods in the real exam. All good mock exam simulators e.g. Whizlabs and Enthuware contains a lot of questions testing and explaining these key concepts. In this article, I have collated some of the frequently asked questions about abstract class and abstract methods in Java. You can review these questions before going for Java interview, both telephonic and face-to-face round. They are also very useful if you are preparing for Oracle Java certification e.g. OCAJP.