Cracking the Protected Modifier

Report a typo

Consider the following Java code snippet, what will be the output, if any. If there will be some complications, choose the correct explanations from the given options:

package pkgA;

public class Foo {
    protected int x;
}

package pkgB;

import pkgA.Foo;

public class Bar extends Foo {
    public static void main(String[] args) {
        Foo fooObj = new Foo();
        System.out.println(fooObj.x);
    }
}
Select one option from the list
___

Create a free account to access the full topic