April 4, 2017

Blog

Shallow vs Deep comparison of objects

Mary : “Which car you own?” Lucy : “I have FIAT 500X” Mary : “Hey…we have same car. I too have FIAT 500X”   You must have heard about comparing two objects in Java using == and equals() method. What is the difference ? Or what is the difference between deep and shallow comparison ? Read more about Shallow vs Deep comparison of objects[…]

Posted in blog | 2 Comments

Decorator Design Pattern

Henry went to the restaurant and ordered one chicken biriyani. After 5 minutes the waiter brought the biriyani. Once when started eating Henry noticed that there is an egg in the biriyani along with two chicken pieces. Thinking that the waiter would have put that egg by mistake Henry called him and told, “I ordered Read more about Decorator Design Pattern[…]

Posted in blog | 10 Comments

Scope of variables in Java

void doStuff() {       for (int i = 0; i < 4; i++) {            boolean flag = false;            if (i == 3) { flag = true; } } System.out.println(flag); } I’m sure the compiler will do this : Compiler will say that I have no memory Read more about Scope of variables in Java[…]

Posted in blog | 9 Comments

ClassCastException

Thrown to indicate that the code has attempted to cast an object to a subclass of which it is not an instance. — Official statement. A guaranteed ClassCastException 😀     ClassCastException is a runtime exception belongs to java.lang package.   Object in = 10; String s = (String)in;   The above code compiles but Read more about ClassCastException[…]

Posted in blog | 4 Comments

Serialization

  An object asks “Whenever I’m created, I stay in the heap memory.  Is it possible for you to persist me somewhere? ” Yes it is possible. An object and its instance variables can be saved into a physical device. Object serialization saves the state of an object as sequence of bytes and at later Read more about Serialization[…]

Posted in blog | 5 Comments