Skip to content

Compile time vs Run time Summary

Jed edited this page Nov 29, 2020 · 5 revisions
Compile-time Run-time
Type Left hand side of the assignment,
fixed upon declaration
Right hand side of the assignment,
vary as program runs
Binding Static Dynamic
Control Restricts methods that can be called based on compile-time type Methods to invoke are determined during run-time
Check for Method overloading,
more specific method will be invoked
Method overriding,
overridden method will never be invoked

What happens during Compilation Time in Java?

  1. Type Inference
  • Inferring the type of a variable whose types are not defined.
  1. Type Erasure
  • Replacing a type parameter of generics with either Object or its Bond.

What happens during Run Time in Java?

  1. Type Checking
  • Checking if the value matches the type of the variable it is assigned to. It happens during run-time since the value is not always available at compile time.
  1. Late Binding
  • Determines which instance method to call depending on the type of a reference object.

Exceptions

  1. Type Casting
  • Converting the type of one variable to another.
  • Happens during Compile time but checked during run time.
  1. Accessibility Checking
  • Checks if a class has access to a field in another class.
  • Happens in both Compile and Run Time.
Clone this wiki locally