Home / Java Programming / Declarations and Access Control :: Discussion

Discussion :: Declarations and Access Control

  1. Which is a valid declaration within an interface?

  2. A.
    public static short stop = 23;
    B.
    protected short stop = 23;
    C.
    transient short stop = 23;
    D.
    final void madness(short stop);

    View Answer

    Workspace

    Answer : Option A

    Explanation :

    (A) is valid interface declarations.

    (B) and (C) are incorrect because interface variables cannot be either protected or transient. (D) is incorrect because interface methods cannot be final or static.


Be The First To Comment