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 amazon.com.
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.
class JSC201 {
static byte m1() {
final char c1 = '\u0001';
return c1; // 1
}
static byte m2(final char c2) {return c2;} // 2
public static void main(String[] args) {
char c3 = '\u0003';
System.out.print(""+m1()+m2(c3)); // 3
}}
What is the result of attempting to compile and run the program?
| a. | Prints: 13 |
| b. | Prints: 4 |
| c. | Compile-time error at 1 |
| d. | Compile-time error at 2 |
| e. | Run-time error |
| f. | None of the above |
class JSC202 {
static byte m1() {final short s1 = 2; return s1;} // 1
static byte m2(final short s2) {return s2;} // 2
public static void main(String[] args) {
short s3 = 4;
System.out.print(""+m1()+m2(s3)); // 3
}}
What is the result of attempting to compile and run the program?
| a. | Prints: 24 |
| b. | Prints: 6 |
| c. | Compile-time error at 1. |
| d. | Compile-time error at 2. |
| e. | Run-time error |
| f. | None of the above |
class JSC203 {
static int m1(byte b) {return b;} // 1
static int m2(char c) {return c;} // 2
static int m3(long l) {return l;} // 3
public static void main(String[] args) {
byte b = 1; char c = '\u0002'; long l = 4L;
System.out.print(""+m1(b)+m2(c)+m3(l));
}}
What is the result of attempting to compile and run the program?
| a. | Prints: 124 |
| b. | Prints: 7 |
| c. | Compile-time error at 1. |
| d. | Compile-time error at 2. |
| e. | Compile-time error at 3. |
| f. | Run-time error |
class JSC204 {
static int m1(short s) {return s;} // 1
static int m2(float f) {return f;} // 2
public static void main(String[] args) {
short s = 3; float f = 5.0f;
System.out.print(""+m1(s)+m2(f));
}}
What is the result of attempting to compile and run the program?
| a. | Prints: 35.0 |
| b. | Prints: 8.0 |
| c. | Compile-time error at 1. |
| d. | Compile-time error at 2. |
| e. | Run-time error |
| f. | None of the above |
class JSC205 {
static int m1(int i) {return i;} // 1
static void m2(int i) {return i;} // 2
static int m3(int i) {return;} // 3
public static void main(String[] args) {
System.out.print(""+m1(1)+m2(2)+m3(3)); // 4
}}
What is the result of attempting to compile and run the program?
| a. | Prints: 123 |
| b. | Prints: 6 |
| c. | Compile-time error at 1. |
| d. | Compile-time error at 2. |
| e. | Compile-time error at 3. |
| f. | Compile-time error at 4. |