What is the purpose of serialization?

Serialization is the conversion of an object to a series of bytes, so that the object can be easily saved to persistent storage or streamed across a communication link. The byte stream can then be deserialised – converted into a replica of the original object. In Core Java, serialization refers to the process of converting … Read more

What if you have a specific scenario where you want to first sort by rank and then alphabetically if the ranks are same?

Any number of Comparator classes can be created to sort them differently as shown below. import java.util.Comparator;   public class JavaTechnologyComparator implements Comparator<JavaTechnology> {   @Override public int compare(JavaTechnology t1, JavaTechnology t2) {   //handle null values here Integer rank1 = t1.getRank(); Integer rank2 = t2.getRank(); int rankVal = rank1.compareTo(rank2); int nameVal = t1.getName().toLowerCase().compareTo(t2.getName().toLowerCase());   … Read more

Can you write a simple program that compares two objects to return if they are equal or not? This method will be handy in defining your own equals( ) method.

This is usefull in domain or value object class to compare different object fields in an equals method public class DomainObject {   //protected because only inheriting domain classes can use it protected boolean isPropertyEqual(Object compare1, Object compare2) { // go here if compare1 is null, i.e. test cases 1 & 3 if (compare1 == … Read more

What is comment ?

In an XML document, text that is ignored unless the parser is specifically told to recognize it. In advanced Java, as well as in any programming language, a comment is a piece of text that is not executed by the compiler or interpreter. Comments are added to the source code to provide explanations, document the … Read more

What is client-certificate authentication ?

An authentication mechanism that uses HTTP over SSL, in which the server and, optionally, the client authenticate each other with a public key certificate that conforms to a standard that is defined by X.509 Public Key Infrastructure. Client-certificate authentication is a method of authentication where a client (such as a web browser or another application) … Read more