Which of the following statements is/are true regarding JAVA? A. Constants…

2022

Which of the following statements is/are true regarding JAVA? A. Constants that cannot be changed are declared using the “Static” keyword. B. A class can inherit only one class, but it can implement multiple interfaces.

  1. A.

    A is true

  2. B.

    B is true

  3. C.

    Both (A) and (B) are true

  4. D.

    Neither (A) nor (B) is true

Attempted by 158 students.

Show answer & explanation

Correct answer: B

  1. Constants in Java (Statement A)

  • The final Keyword: This is the actual "constant" modifier. Once a final variable is initialized, it cannot be reassigned.

  • The static Keyword: This simply means the variable belongs to the class itself rather than a specific instance (object).

  • The Difference: You can have a static variable that is not final (it's shared by all objects but can change), and you can have a final variable that is not static (each object has its own constant value).

2. Inheritance and Interfaces (Statement B)

Java uses a very specific model to keep code clean and manageable:

  • Classes: A class can extend only one other class. This prevents the "Diamond Problem" where a class might inherit conflicting methods from two different parents.

  • Interfaces: A class can implement any number of interfaces. This allows for great flexibility because interfaces only define "what" a class must do, not "how" it does it (until the introduction of default methods, but the inheritance rule remains the same).

Explore the full course: Up Lt Grade Assistant Teacher 2025