Java is a ______ language. This means that you must be explicit about what…
2017
Java is a ______ language. This means that you must be explicit about what type of data you are working with.
Answer: B. strongly typed — Concept: A language's type system is described on two independent axes. Strength is about how firmly the type rules are enforced: a strong system keeps every…
- A.
weakly typed
- B.
strongly typed
- C.
dynamically typed
- D.
loosely typed
Attempted by 744 students.
Show answer & explanation
Correct answer: B
Concept: A language's type system is described on two independent axes. Strength is about how firmly the type rules are enforced: a strong system keeps every value bound to the type it was created with and permits an operation only where the language defines a type-safe meaning for it, so a value is never silently reinterpreted as an unrelated type. Binding time is about when the type is settled: a static system fixes each variable's type in the source code and checks it before the program runs, while a dynamic system attaches the type to the value while the program is running.
Application: Java sits at the strict end of both axes. Every variable is declared with a type, as in int count = 5; or String name = "KG";, and the compiler checks each assignment and each operation against those declarations, so String s = 5; is rejected before the program ever runs. Java does define a set of type-safe implicit conversions, such as widening a smaller numeric type into a wider one in long total = count;, but a conversion that can lose information or that crosses unrelated types has to be written by the programmer as a cast, as in int x = (int) 3.9;. That controlled discipline is what strict enforcement means.
The clause in the question, that you must be explicit about the type of data you are working with, actually describes the static half of Java’s type system, and the term "statically typed" is not among the given options. Oracle’s Java Language Specification calls Java both a statically typed and a strongly typed language, and of the four terms offered only strongly typed names a classification that Java really carries.
How the four offered terms compare:
Term | What the term means |
|---|---|
strongly typed | Type rules are enforced strictly: a value stays bound to its type and only operations with a type-safe meaning are permitted, so any other conversion must be written as a cast. This is Java's classification. |
weakly typed | Enforcement is relaxed: operands of unrelated types are coerced automatically, so a mixed expression still yields a value. |
loosely typed | An informal label for the same permissive discipline as weak typing, not a separate behaviour. |
dynamically typed | About binding time rather than strictness: the type rides with the value at run time and is not declared in the source code, so a mismatch surfaces only when that line executes. Java settles types at compile time. |
So the blank is filled by strongly typed.
A video solution is available for this question — log in and enroll to watch it.