Which two actions, used independently, will permit this class to compile?

Given:


Which two actions, used independently, will permit this class to compile?
A. Adding throws IOException to the main() method signature
B. Adding throws IOException to the doSoomething() method signature
C. Adding throws IOException to the main() method signature and to the dosomething() method
D. Adding throws IOException to the dosomething() method signature and changing the catch argument to IOException
E. Adding throws IOException to the main() method signature and changing the catch argument to IOException

Download Printable PDF. VALID exam to help you PASS.

One thought on “Which two actions, used independently, will permit this class to compile?

  1. C
    anser C is correct

    public class dcdc {

    public static void main(String[] args)throws IOException{
    try {
    doSomething();
    }
    catch(RuntimeException e)
    {
    System.out.println();
    }

    }
    static void doSomething() throws IOException {
    if(Math.random()>0.5) throw new IOException() ;

    throw new RuntimeException();

    }

    }
    /////////////////////////////////////////////////////////////////////////////////////////////

    anser D is correct

    public class dcdc {

    public static void main(String[] args){
    try {
    doSomething();
    }
    catch( IOException e)
    {
    System.out.println();
    }

    }
    static void doSomething() throws IOException {
    if(Math.random()>0.5) throw new IOException() ;

    throw new RuntimeException();

    }

    }

Leave a Reply

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


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