Which three code fragments are valid at line n1?

Given the code fragment:

Which three code fragments are valid at line n1? (Choose three.)
A.

B.

C.

D.

E.

Download Printable PDF. VALID exam to help you PASS.

10 thoughts on “Which three code fragments are valid at line n1?

  1. Wrong and why
    B – cannot have a body if abstract
    C – needs to be abstract if no body is provided

  2. per compilation below, NOT correct ones are B and C

    # javac Test21.java
    Test21.java:9: error: abstract methods cannot have a body
    public abstract Toy getToy() {
    ^
    Test21.java:13: error: missing method body, or declare abstract
    public void printToy();
    ^
    2 errors

Leave a Reply

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