What is difference between overloading and overriding

a) In overloading, there is a relationship between methods available in the same class whereas in overriding, there is relationship between a superclass method and subclass method. b) Overloading does not block inheritance from the superclass whereas overriding blocks inheritance from the superclass. c) In overloading, separate methods share the same name whereas in overriding, … Read more

What is method overloading and method overriding

Method overloading: When a method in a class having the same method name with different arguments is said to be method overloading. Method overriding : When a method in a class having the same method name with same arguments is said to be method overriding. In Java, method overloading and method overriding are two important … Read more

What are Transient and Volatile Modifiers?

Transient: The transient modifier applies to variables only and it is not stored as part of its object’s Persistent state. Transient variables are not serialized. Volatile: Volatile modifier applies to variables only and it tells the compiler that the variable modified by volatile can be changed unexpectedly by other parts of the program. In Java, … Read more

What is finalize() method?-

finalize () method is used just before an object is destroyed and can be called just prior to garbage collection. In Core Java, the finalize() method is a method provided by the Object class. It is called by the garbage collector when it determines that there are no more references to the object. The purpose … Read more

What is Garbage Collection and how to call it explicitly?

When an object is no longer referred to by any variable, java automatically reclaims memory used by that object. This is known as garbage collection. System. gc() method may be used to call it explicitly. In Java, garbage collection is a process by which the Java Virtual Machine (JVM) automatically manages memory by reclaiming the … Read more