In: Computer Science
1 .RuntimeException class is a subclass of the Exception class. Fill in the blanks to complete the declaration of the RuntimeException class. _____________ ________________ _________________
. |
||
. |
||
. |
||
3. RuntimeException is a subclass of Exception. The constructor RuntimeException(String message) calls the parent class's constructor with the message argument. Which of the following makes the call correctly?
this(message); |
||
super(message); |
||
super.Exception(message); |
||
Exception(message); |
4. RuntimeException has overloaded constructors: the 1-argument constructor RuntimeException(String message) and the 2-argument constructor RuntimeException(String message, Throwable cause).
The 2-argument constructor calls the 1argument constructor with message as the argument. Which of the following makes the call correctly?
this(message); |
||
RuntimeException(message); |
||
this.RuntimeException(message); |
5. RuntimeException is a sublcass of Exception. Both classes have a constructor that takes a String argument. Among the statements below, indicate all that are syntactically correct.
Exception e = new Exception("Division by zero problem"); |
||
Exception e = new RuntimeException("Division by zero problem"); |
||
RuntimeException e = new Exception("Division by zero problem"); |
||
RuntimeException e = new RuntimeException("Division by zero problem"); |
6. Payable is an interface with one method payableAmount() that returns double.
(1) The source code of the interface is saved in a file named ____________java
(2) Fill in the blanks to complete code for the interface:
public ____________________ Payable {
public abstract _______________payableAmount();
}
7. The Student class implements the Payable interface without actually implementing the only payableAmount() method declared in the interface. Fill in the blanks to complete the declaration of the Student class:
public _________ class __________ ___________ __________
8. SQLException is unchecked exception, hence handling such exception is optional.
True
False
9. An abstract class can have constructors even though it cannot be instantiated.
True
False
10. In Java, a class can implement more than one interface.
True
False
1.
public class RuntimeException extends Exception{
/**
*
*/
private static final long serialVersionUID = 1L;
public RuntimeException(String message) {
// TODO Auto-generated constructor stub
super(message);
}
public RuntimeException(String message, Throwable t) {
// TODO Auto-generated constructor stub
this(message);
}
}
3.super(message);
4.this(message);
5..RuntimeException e = new RuntimeException("Division by zero
problem")
6. Payable is an interface with one method payableAmount() that returns double.
(1) The source code of the interface is saved in a file named Payable.java
(2) Fill in the blanks to complete code for the interface:
public interface Payable {
public abstract _____double payableAmount();
}
7. The Student class implements the Payable interface without actually implementing the only payableAmount() method declared in the interface. Fill in the blanks to complete the declaration of the Student class:
public abstract class Student implements Payable
8. SQLException is unchecked exception, hence handling such exception is optional.
True [Like Runtime also]
9. An abstract class can have constructors even though it cannot be instantiated.
True
10. In Java, a class can implement more than one interface.
True