Which class is super class of every class

Late binding early binding java

OR
What is late binding and early binding in java

Answer :

Late bindingEarly binding
Late binding applies at runtimeEarly binding applies at compile time
Object type are unknown until runtime and its value will be assigned dynamicallyVariable type are known and check at compile time i.e. when you define variable static
Method dynamic dispatch is an example of late binding through which we achieve polymorphismStatic blocks are example of early binding
Method overriding is an example of late bindingMethod overloading is an example of early binding

Please see example below:

package com.javahonk.earlylatebinding;

import java.util.HashMap;
import java.util.Map;

public class EarlyLateBinding {

	// Early binding
	private static final Map<String, String> MAP = 
			new HashMap<String, String>();
	// Early binding
	static {
		MAP.put("First Name: ", "Java");
		MAP.put("Last Name: ", "Honk");
	}

	public static void main(String[] args) {
		A a = new B();

		if (a instanceof B) {
			System.out.println("Late binding");
		}

	}

}

class B extends A {

}

class A {

}

 

Output:


Late binding early binding java

Leave a Reply

Your email address will not be published. Required fields are marked *