Autoboxing and Unboxing: Primitive data types storing in Array Lists

As we are aware that the ArrayLists in Java stores the pointers to objects. Then how can I store the primitive datatypes inside the ArrayLists. Because when storing the int type in ArrayLists it’s showing the below mentioned error in IDE. Same thing will happen for data type double also as shown below:- So, here…

Is the method Overriding and Polymorphism are same in Java?

Polymorphism is one of the characteristics of object oriented programming. Poly means many and Morph means :- Overriding of a method is nothing but smooth modification of a method that is inherited from super class by it’s subclass. So it’s like smooth change or modification of the method of the superclass. So, from this above…

Composition in java with examples

In one sentence composition in java is used to fulfill the HAS-A relationship. Just imagine one scenario. In the above picture John is flying his own helicopter. So John has a Red two seater helicopter and also John has two hands. So if I consider John as a class, then two instance variables are like…