Review Questions

4.17 Given the following definition of a class, which fields are accessible from outside the package com.corporation.project?
package com.corporation.project;

public class MyClass {
              int i;
    public    int j;
    protected int k;
    private   int l;
}

Select the two correct answers.

  1. Field i is accessible in all classes in other packages.

  2. Field j is accessible in all classes in other packages.

  3. Field k is accessible in all classes in other packages.

  4. Field k is accessible in subclasses only in other packages.

  5. Field l is accessible in all classes in other packages.

  6. Field l is accessible in subclasses only in other packages.

4.18 How restrictive is the ...

Get Programmer's Guide to Java™ Certification, A: A Comprehensive Primer, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.