Multiple choice technology programming languages

We all know about the Dynamic dispatch in java. But if there is dynamic dispatch , then is there a Static dispatch also? (Easy One...)

  1. True

  2. False

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

Java has both static and dynamic dispatch. Static dispatch occurs for private, static, and final methods - these are resolved at compile time based on the declared type. Dynamic dispatch (virtual method invocation) occurs for overridden instance methods, resolved at runtime based on the actual object type.

AI explanation

To answer this question, let's go through each option to understand why it is correct or incorrect:

Option A) True - This option is correct. In Java, static dispatch refers to the binding of a method call to its declaration at compile-time, based on the static type of the reference variable. This means that the method to be called is determined at compile-time and does not change at runtime.

Option B) False - This option is incorrect. Static dispatch does exist in Java.

The correct answer is A) True. This option is correct because static dispatch is a concept in Java where the method to be called is determined at compile-time based on the static type of the reference variable.