class A {A(int i) {}} // 1
class B extends A {} // 2
Which of the following statements are true?
| a. | The compiler attempts to create a default constructor for class A. |
| b. | The compiler attempts to create a default constructor for class B. |
| c. | Compile-time error at 1. |
| d. | Compile-time error at 2. |
Which of the following modifiers can be applied to a constructor?
| a. | private |
| b. | abstract |
| c. | final |
| d. | volatile |
| e. | native |
| f. | None of the above. |
Which of the following techniques can be used to prevent the instantiation of a class by any code outside of the class?
| a. | Do not declare any constructors. |
| b. | Do not use a return statement in the constructor. |
| c. | Declare all constructors using the keyword void to indicate that nothing is returned. |
| d. | Declare all constructors using the private access modifier. |
| e. | None of the above. |
Which of the following modifiers can be applied to a constructor?
| a. | protected |
| b. | public |
| c. | static |
| d. | synchronized |
| e. | transient |
Which of the following statements are true?
| a. | The compiler will create a default constructor if no other constructor is declared. |
| b. | The default constructor takes no arguments. |
| c. | If a class A has a direct superclass, then the default constructor of class A invokes the no-argument constructor of the superclass. |
| d. | The default constructor declares Exception in the throws clause. |
| e. | The default constructor is always given the private access modifier. |
| f. | The default constructor is always given the public modifier. |
| g. | The default constructor is always given default package access. |
Suppose that the compiler generates a default constructor for a class. If a compile-time error is to be avoided, which of the following must be true?
| a. | The superclass must not have any constructor other than a default constructor. |
| b. | The superclass must not have an accessible no-argument constructor. |
| c. | The no-argument superclass constructor must not have a throws clause that includes a checked exception. |
| d. | The no-argument superclass constructor must be declared private. |
| e. | None of the above |
class A {A() throws Exception {}} // 1
class B extends A {B() throws Exception {}} // 2
class C extends A {} // 3
Which of the following statements is true?
| a. | Compile-time error at 1. |
| b. | Compile-time error at 2. |
| c. | Compile-time error at 3. |
| d. | None of the above |