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

Discussion :: Declarations and Access Control

  1. What will be the output of the program?

    public class Test  {       public static void main(String args[])     {          class Foo          {             public int i = 3;         }          Object o = (Object)new Foo();         Foo foo = (Foo)o;         System.out.println("i = " + foo.i);     } } 

  2. A.
    i = 3
    B.
    Compilation fails.
    C.
    i = 5
    D.
    A ClassCastException will occur.

    View Answer

    Workspace

    Answer : Option A

    Explanation :

    No answer description available for this question. Let us discuss.


Be The First To Comment