Monday, 31 October 2016

Java Source World: Covariant Return Type in Java

Covariant Return Type in Java | Java Source World                                                                     Javasourceworld                   A Java quick reference blog  Covariant Return Type in Java The covariant return type specifies that the return type may vary in the same direction as the subclass. Before Java5, it was not possible to override any method by changing the return type. But now, since Java5, it is possible to override method by changing the return type if subclass overrides any method whose return type is Non-Primitive but it...
Read More »

Sunday, 30 October 2016

Java Source World: Association, Aggregation, Composition

Association, Aggregation, Composition | Java Source World                                                                   Javasourceworld                   A Java quick reference blog Association, Aggregation, Composition Association: Association is a relationship where all objects have their own life cycle and there is no owner.  For Example: Teacher and Student Explanation: A single Teacher object can have more Students or A single Student can associate with multiple Teachers. But there is no ownership between these two objects...
Read More »

Friday, 28 October 2016

Java Source World: Equals and HashCode in java

Equals and HashCode in java Equals and HashCode: Equals and HashCode methods in Java are two fundamental methods from java.lang.Object class, which is used to compare equality of objects, primarily inside hash based collections such as Hashtable and HashMap. Both equals() and hashCode() are defined injava.lang.Object class and there default implementation is based upon Object information e.g. default equals() method return true, if two objects are exactly same i.e. they are pointing to same memory address, while default implementation of hashcode method return int and implemented as native method. Similar default implementation of toString() method, returns type of class, followed bymemory address in...
Read More »

Java Source World: Serialization in Java

Serialization in Java | Java Source World                                                            Javasourceworld                         A Java quick reference blog Serialization in Java | Why we need to implement Serializable interface in java  java.io.Serializable Interface : This interface is used to mark serialization and deserialization of an object. Serialization is a process in which an object state is read from memory and written into a file or a database. Deserialization is a process in which an object state is read from a file or a database...
Read More »

Wednesday, 26 October 2016

Java Source World: What Are Marker Interfaces In Java

What Are Marker Interfaces In Java Marker interfaces:  Marker interfaces in java are interfaces with no members declared in them. They are just an empty  interfaces used to mark or identify a special operation. For example, Cloneable interface is used to mark cloning operation and Serializable interface is used to mark serialization and deserialization of an object. Marker interfaces give instructions to JVM that classes implementing them will have special behavior and must be handled with care. Marker interfaces don’t provide any functionality. In earlier versions of Java (Before Java 5), marker interfaces are used to provide metadata to the readers. With the introduction of annotations from Java 5, annotations are used more instead...
Read More »