Which two modifications, made independently, enable the code to compile?

Given the code fragment:

Which two modifications, made independently, enable the code to compile?
A. Make the method at line n1 public.
B. Make the method at line n2 public.
C. Make the method at line n3 public.
D. Make the method at line n3 protected.
E. Make the method at line n4 public.

Download Printable PDF. VALID exam to help you PASS.

4 thoughts on “Which two modifications, made independently, enable the code to compile?

  1. CD
    line 4 compile without change.

    abstract public class Planet {
    protected void revolve(){}
    abstract void rotate();

    }
    class Earth extends Planet{
    @Override
    public/protected void revolve() {

    }

    @Override
    protected / public / default void rotate() {

    }
    }

  2. CD are correct because the overriding method must not be more restrictive, should be the same or more visible.

  3. made independently, i see why if we only make the method at line n4 public, the code still fail to compile, we should focus on what is the reason make the code fail to compile then fix it.

Leave a Reply

Your email address will not be published. Required fields are marked *


The reCAPTCHA verification period has expired. Please reload the page.