The pages of this web site are not formatted to conserve paper, but my new book (ISBN: 0-9745862-0-X) is formatted to save paper, save your printer cartridge, save a loose-leaf binder, and save money. If you prefer to work my exams from printed pages, then give your printer a rest and buy my new book.
Today, you can find my book at BookSurge.com.
Are you a university student studying Java programming? Do you agree that my book would serve as a helpful workbook and companion to be used along with the Java fundamentals textbook that is currently being used in your class? If so, then please ask your professor to consider using my book in future classes.
If you have any questions or comments concerning my mock exams or my book, then please send an e-mail to me at scjpexam2000@yahoo.com.
I would also like to read your response to the following questions.
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 |