What is the result?

Given the code fragment:

What is the result?
A. Reading Card
Checking Card
B. Compilation fails only at line n1.
C. Compilation fails only at line n2.
D. Compilation fails only at line n3.
E. Compilation fails at both line n2 and line n3.

Download Printable PDF. VALID exam to help you PASS.

One thought on “What is the result?

  1. D
    void readCard(int cardNo) throws Exception{
    System.out.println(“Read card”);
    }
    void checkCard(int cardNo) throws RuntimeException{
    System.out.println(“Check card”);
    }

    public static void main(String[] args) {
    int cardNo=12344;
    Q131 ex = new Q131();
    ex.checkCard(cardNo);
    // ex.readCard(cardNo);//not compile u have to put throws Exception in main method (declare or handel check Exception )
    }

Leave a Reply

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


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