Difference between Abstraction and Encapsulation in Java - OOP

Abstraction vs Encapsulation – Java OOP
Abstraction and Encapsulation in Java are two important Object oriented programming concept and they are completely different from each other. The only similarity between Abstraction and Encapsulation is that they are OOP concept, other than that they mean two different things. Abstraction represent taking out the behavior from How exactly it implemented, one example of abstraction in Java is interface while Encapsulation means hiding details of implementation from the outside world so that when things change nobody gets affected.

Can we override static method in Java - Method Hiding

Can we override static method in Java
No, you cannot override static method in Java because method overriding is based upon dynamic binding at runtime and static methods are bonded using static binding at compile time. Though you can declare a method with same name and method signature in sub class which does look like you can override static method in Java but in reality that is method hiding. Java won't resolve method call at runtime and depending upon type of Object which is used to call static method, corresponding method will be called. It means if you use Parent class's type to call static method, original static will be called from patent class, on ther other hand if you use Child class's type to call static method, method from child class will be called.

What is method overriding in Java – Example Tutorial

Method overriding in Java
Method overriding in Java is a concept based on polymorphism OOPS concept which allows the programmer to create two methods with the same name and method signature on the interface and its various implementation and the actual method is called at runtime depending upon the type of an object at runtime. Method overriding allows you to write flexible and extensible code in Java because you can introduce new functionality with the minimal code change. Method overriding is different than the method overloading in Java which we have discussed in the last article.

What is method overloading in Java - Example Tutorial

What is method overloading in Java
Method overloading in Java is a programming concept when programmer declares two methods of the same name but with different method signature, e.g. change in the argument list or change in the type of argument. method overloading is a powerful Java programming technique to declare a method which does a similar performance but with a different kind of input. One of the most popular examples of method overloading is System.out.println() method which is overloaded to accept all kinds of data types in Java. You have println() method which takes String, int, float,double or even char in output. All of those methods are collectively referred as an overloaded method in Java. The difference between method overloading and overriding is also a popular Java interview question. In next section, we will some important points about method overloading in Java and then a simple example of how to overload a method in Java.

Difference between String and StringBuffer in Java

String vs StringBuffer in Java
String and StringBuffer are two classes which are most widely used in any Java program. If I say you can not write a program without using String in Java then it would not be an exaggeration. The string is everywhere, the main method accepts String argument, logs are String etc. Though many Java programmers familiar with String, not many are careful while performing operations on String, Since String is final in Java; every operation e.g. converting String into Uppercase, creating SubString,  converting String to Lowercase all result in a separate new String Object, which can take trigger frequent garbage collection and affect your application performance. here comes StringBuffer in Java which is a mutable version of String, though it's not as feature rich as String and you can not use StringBuffer in place of String but StringBuffer should be used whenever you are performing String concatenation instead of String in Java.

What is Thread and Runnable in Java - Example

What is Thread in Java?
Thread in Java is an independent path of execution that is used to run two tasks in parallel. When two threads run in parallel that is called multithreading in Java. Java is multithreaded from the start and excellent support of Thread at language level e.g. java.lang.Thread class, synchronized keyword, volatile and final keyword makes writing concurrent programs easier in Java than any other programming language e.g. C++. Being multi-threaded is also a reason for Java's popularity and being the number one programming language. On the other hand, if your program divides a task between two threads it also brings a lot of programming challenges and issues related to synchronization, deadlock, thread-safety, and race conditions.

What is class file in Java - How to create Class File

What is class file in Java
Class file in Java is compiled form of Java source file. When we compile Java program which is written in Java source file  ended with .java extension, it produces one more class files depending upon how many classes are declared and defined in that Java source file. One Java source file can only contain one public class and its name must match with name of file e.g. file can contain a public class whose name should be HelloWorld as shown below :

How to traverse iterate or loop ArrayList in Java

How to Loop ArrayList in Java
Iterating, traversing or Looping ArrayList in Java means accessing every object stored in ArrayList and performing some operations like printing them. There are many ways to iterate, traverse or Loop ArrayList in Java e.g. advanced for loop, traditional for loop with size(), By using Iterator and ListIterator along with while loop etc. All the method of Looping List in Java also applicable to ArrayList because ArrayList is an essentially List. In next section we will see a code example of Looping ArrayList in Java.

Difference between HashMap and ConcurrentHashMap in Java Collection

HashMap vs ConcurrentHashMap in Java
ConcurrentHashMap in Java is introduced as an alternative of Hashtable in Java, which is a synchronized collection class, that makes the main difference between HashMap and ConcurrentHashMap which is one is non-synchronized , non-thread safe and not for use in Concurrent multi-threaded environment while ConcurrentHashMap is a thread-safe collection and intended to be used as primary Map implementation especially for multi-threaded and Concurrent environment. Apart from thread-safety, there are some subtle differences between HashMap and ConcurrentHashMap which we will see in this article.

Video example - Dijkstra's Algorithm shortest path in Graph

Video example - Dijkstra's Algorithm shortest path in Graph

Dijkstra's Algorithm in Graph theory allows you to find least cost path or shortest path between two nodes in directed and weighted graph. Dijkstra's Algorithm is one of the important concept of Graph theory and often asked in Exams and interviews. Frankly speaking Its not easy to understand Dijkstra's Algorithm , at least until you have a good example and this leads me to search for simple and easy to learn example of Dijkstra's Algorithm which landed me on this video. I have earlier shared Graph traversal BFS and DFS algorithm from this same author and when I found his video on Dijkstra's Algorithm, I knew this is going to be another best. By the way Dijkstra's Algorithm has several practical usage like finding shortest path between cities for Air planes route or bus route as cities and driving path between cities fits nicely
as vertices of Graph and directed and weighted path between them. In Dijkstra's Algorithm , path between two nodes which are unreachable directly is assumed as infinity. I suggest watching this video example more than one time if you are unsure how Dijkstra's Algorithm works.