Java代写 | COMP10062: Final Exam

本次加拿大代写主要为JAVA的限时测试

A. Knowledge and Understanding

1. Write a single line of code that will throw an IllegalArgumentException containing the
message “Nice try”.

2. Write code to call a method named testMethod(). This method might throw an
IllegalArgumentException. Include code to catch that exception and print the message
contained in that exception to System.out.

3. Write code to create an empty class named Child that inherits all its methods and instance
variables from a class named Parent.

4. Given the UML diagram and the declaration for the variable c below, put a check mark beside all the
assignments that are legal and an X beside those that are illegal.

5. Consider the UML diagram and the code below. When the code is run, how many calls will there be
to a draw method, and which draw method(s) will be called in each case?

6. Write the code necessary to create an array and fill it with 1000 objects of type Donut (see the
previous question for the Donut class).

7. Write code to declare an abstract class named ABS that contains an abstract method named absm
that will return a String and has no parameters.

8. Write the minimum amount of code necessary to implement
just the Owner class as shown at right. Assume the other classes have already been implemented.

9. Write the code for an abstract class named “Abs” that contains an abstract method called “foo”.
The abstract method has two integer parameters and returns a String.