April 4, 2017

Blog

Pass by Value and Pass by Reference

Let’s try to understand how pass by value and pass by reference works in Java.   It is very simple and read the next sentence twice☺️. In Java no matter what type of argument you pass the corresponding parameter (primitive variable or object reference) will get a copy of that data, which is exactly how pass-by-value Read more about Pass by Value and Pass by Reference[…]

Posted in blog | 11 Comments

Association, Composition and Aggregation in Java

I was very bored at home yesterday, wanted to engage with something new. Suddenly thought about the old carom board and I searched for it in the store room.I found the set of coins but the board was damaged. Is there any significance for that coins without that carom board? No! Which means these two Read more about Association, Composition and Aggregation in Java[…]

Posted in blog | 24 Comments

Lambda

Functional interface and Marker interface were close friends and one day night they were walking through a forest. They were scared as they knew the fact that anything dangerous can happen to them at any time in the forest.  Suddenly they saw a bear approaching them. Marker interface tried to pull the gun from his Read more about Lambda[…]

Posted in blog | 17 Comments

finalize()

Student:              What happened Sir? No blogs now a days? Sir:                          I fell down from steps and there is a fracture on my right hand. So I cannot write till the plaster is removed. Student:              Oh…I’m sorry. Are you okay now? Sir:                          I’m fine. Only some difficulties as I cannot use my right hand now. Read more about finalize()[…]

Posted in blog | 31 Comments

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 | 26 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 | 27 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 | 26 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 | 11 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 | 28 Comments