Multiple Choice Question

Quiz Guidelines

 

QID: 
539
Question: 

Consider the following

public class TestClass {
public static void main(String[] args) { 
TestClass tc = new TestClass(); 
tc.myMethod();
}
public void myMethod() { 
yourMethod();
}
public void yourMethod() { 
throw new Exception();
}
}

What changes can be done to make the above code compile?

Select 1 option

A. Change declaration of main to 
          public static void main(String[] args) throws Exception
B. Change declaration of myMethod to
          public void myMethod throws Exception
C. Change declaration of yourMethod to
          public void yourMethod throws Exception
D. Change declaration of main and yourMethod to 
          public static void main(String[] args) throws Exception and
          public void yourMethod throws Exception
E. Change declaration of all the three method to include throws Exception.

Q&A Set: