Difference between transient vs volatile variable or modifier in Java

transient vs volatile modifier in Java
What is difference between transient and volatile variable or modifier in Java is one of the most common Serialization Interview Question in Java. Though volatile variables are not related to Serialization at all, this question is mostly asked in conjunction with other Serialization question. Both transient and volatile modifiers are completely different to each other. In fact this question is as popular as Serializable vs Externalizable in Java. Main difference between transient vs volatile variable is that transient variables are not serialized during Serialization process in Java while volatile variables are used to provide alternative synchronization in Java. By using volatile keyword or modifier on fields, signals compiler that this variable is accessed by multiple thread and any reordering or optimization by compiler should be avoided. In this Java article we will see some difference between transient and volatile variable by learning each of them and When to use transient and volatile variable in Java.

10 points about Static in Java

What is static in Java
Static in Java is related to class, if a field is static means it belongs to class, similarly static method belongs to classes and you can access both static method and field using class name e.g. if count field is static in Counter class than you can access it as Counter.count, of course subject to restriction applied by access modifier e.g. private fields are only accessible in class on which they are declared, protected fields are accessible to all classes in same package but only accessible in sub class outside package. See private vs protected vs public for complete details on access modifier. Similarly if you have a static method increment() in Counter class which increment counter than you can call it as Counter.increment(). There is no need to create an object of Counter class to access either static method or static field, this is main difference between static and non static members.

Difference between method and constructor in Java

What is difference between method and constructor in Java is very common questions on beginner level Java interviews with 2 to 3 year experience. Since constructor is kind of special and it has it's own properties which separates it from any normal Java method, this question make sense. Main difference between Constructor and Method is that, you need to call method explicitly but constructor is called implicitly by Java programming language during object instantiation. It doesn't mean you can not call Constructor; if you have overloaded constructor than you can call them using  this keyword as this() constructor, you can even call super class constructor using super() keyword, in-fact that is done automatically by Java compiler if no explicitly constructor is called and that is known as constructor chaining in Java. Like many other beginner level questions e.g. Vector vs ArrayList, We will see difference between method and constructor in Java in point form to understand important properties of each of them clearly.

Java ArrayList Examples For Programmers

ArrayList Example in Java
In this Java ArrayList Example we will see how to add elements in ArrayList, how to remove elements from ArrayList, ArrayList contains Example and several other ArrayList functions which we use daily. ArrayList is one of the most popular class from Java Collection framework along with HashSet and HashMap and a good understanding of ArrayList class and methods is imperative for Java developers. ArrayList is an implementation of List Collection which is ordered and allow duplicates.  ArrayList is alos index based and provides constant time performance for common methods e.g. get().Apart from very popular among Java programmers, ArrayList is also a very popular interview topic.