Posts

Singly Linked List and Doubly Linked List difference

Image
Difference SLL contains two field - data field and next link field. DLL contains three field - data field, previous link field, next link field. The traversal of SLL is done only in one direction i.e. through next node link. But the traversal of DLL is done in both directions i.e. either through previous node link or the next node link. SLL contains more memory than DLL because it less field than DLL. The complexity of insertion and deletion of a SLL is O(n). The complexity of insertion and deletion of a DLL is O(1) Reference https://www.geeksforgeeks.org/difference-between-singly-linked-list-and-doubly-linked-list/amp/

Waterfall and Agile Model difference

Image
Overview Waterfall and Agile both are the models of Software development lifecycle. Difference In Waterfall model, a development team moves on to the next phase if the previous phase is complete. It goes for the same for testing team. Whereas in Agile model, model, development and testing team, all goes hand in hand. Waterfall follows sequential approach but Agile follows incremental approach. In project development phase you can't make changes in Waterfall model, but you can make changes in the Agile model, if there is a change in requirement.

Inheritance in Java

Image
Overview Inheritance is a concept of inheriting methods and properties of another class. Type of Inheritance Single Inheritance Class A->B: B extends A Multilevel Inheritance Class A->B->C: C extends B and B extends A Hierarchical Inheritance Class A->B->C->D: D, C and B extends A Multiple Inheritance Class A->B->C: C extends A and B Hybrid Inheritance Class A->B->C->D: D extends B and C which are a subclass of A. What we can do in Subclass? Subclass can use the inherited properties just like it's own property. Subclass can declare those new properties which are not declared in superclass. Subclass can use the inherited methods just like it's own methods. Subclass can declare those new methods which are not declared in superclass. You can write a constructor in subclass which can call the constructor of a superclass either implicitly or by using the super keyword You can write the same static method in subclass which is declared in superclass, t...

final, finally and finalize difference

Image
Difference Definition:  final is a keyword used as an access modifier. It is used to apply restrictions on a class, object, methods or properties. finally is the Java block which is used with try catch blocks. This block executes whether a block of code throws an exception or not. finalize is a method of Java which is used to perform clean up processing just before an object is garbage collected. Application:  final is used with classes, objects, methods and properties. finally is used with try catch block for Exception handling. finalize is a method used with objects. Functionality: Once declared, final variables becomes constant and cannot be modified in future. final methods cannot be overridden even by a subclass. final class cannot be inherited. Codes written in finally block will execute anyhow, even if there is an exception or not. finally is also used the release the resources used by try catch block. finalize method is used for clean up process of an object which is g...

final keyword in Java

Image
Overview final class cannot be inherited. final methods cannot be overridden. final variables cannot be changed in future.

Polymorphism in Java

Image
Overview Polymorphism is a task that can perform single action in multiple ways. Types of Polymorphism Method Overloading - Using the same method with different type of parameters. Method Overriding - Using the same method which you inherited from your base class. Reference  https://www.mygreatlearning.com/blog/polymorphism-in-java/

Map and HashMap difference

Image
Difference Map is an interface but HashMap is a class. So you cannot create an object of a Map but you can create an object of a HashMap Map <String , Integer> empIds = new Map<>() ; // This will give a compile time error Map <String , Integer> empIds = new HashMap<>() ; // This is allowed Map contains unique key value pairs but HashMap can have duplicate values. Map interface can be implemented by using its implementing class. Whereas HashMap class implements the Map interface. Map is used to create, Hashmap and TreeMap. While HashMap implements Map interface and extends AbstractMap class. There is no difference between the objects of Map and HashMap. Both of them maintains an insertion order. You are not allowed to use primitive data types (int, float, double, char) to define a Map or a HashMap. You have to use non-primitive data types (Integer, Float, Double, Character, String, Objects) to define a Map or HashMap.  Example of Map public class Maps { ...