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 GFM11{
public static void main (String[] args) {
int x,y,z;
System.out.println(x+y+z);
}}
What is the result of attempting to compile and run the program?
| a. | Prints nothing. |
| b. | Prints an undefined value. |
| c. | Prints: null |
| d. | Prints: 0 |
| e. | Run-time error |
| f. | Compile-time error |
| g. | None of the above |
class GFM12 {
static int x; // 1
public static void main(String[] args) { // 2
int y; // 3
System.out.println("x="+x); // 4
System.out.println("y="+y); // 5
}}
What is the result of attempting to compile and run the program?
| a. | Compile-time error at line 1. |
| b. | Compile-time error at line 2. |
| c. | Compile-time error at line 3. |
| d. | Compile-time error at line 4. |
| e. | Compile-time error at line 5. |
| f. | Run-time error |
| g. | None of the above |
class GFM13 {
static byte a; static short b; static char c;
static int d; static long e; static String s;
public static void main(String[] args) {
System.out.println(a+b+c+d+e+s);
}}
What is the result of attempting to compile and run the program?
| a. | Prints: 00000null |
| b. | Prints: 00000 |
| c. | Prints: 0null |
| d. | Prints: 0 |
| e. | Prints: null |
| f. | Compile-time error |
| g. | Run-time error |
| h. | None of the above |
class GFM14 {
static byte a; static short b; static char c;
static int d; static long e; static String s;
public static void main(String[] args) {
System.out.println(a+","+b+","+(int)c+","+d+","+e+","+s);
}}
What is the result of attempting to compile and run the program?
| a. | Prints: 0,0,0,0,0,null |
| b. | Prints: 0,0,0,0,0, |
| c. | Prints: 0,0, ,0,0, |
| d. | Compile-time error |
| e. | Run-time error |
| f. | None of the above |
class GFM15 {
static int a; static float b; static double c;
static boolean d; static String s;
public static void main(String[] args) {
System.out.println(a+","+b+","+c+","+d+","+s);
}}
What is the result of attempting to compile and run the program?
| a. | Prints: 0,0,0,false,null |
| b. | Prints: 0,0,0,false, |
| c. | Prints: 0,0.0,0.0,false,null |
| d. | Prints: 0,0.0,0.0,false, |
| e. | Prints: 0,0.0,0.0,true,null |
| f. | Prints: 0,0.0,0.0,true, |
| g. | Prints: 0,0,0,true,null |
| h. | Prints: 0,0,0,true, |
| i. | Compile-time error |
| j. | Run-time error |
| k. | None of the above |
class GFM16 {
static int m1 (int i1, int i2) {
int i3;
if (i1 > 0) {i3 = i1 + i2;}
return i3;
}
public static void main(String[] args) {
System.out.println(m1(1,2));
}}
What is the result of attempting to compile and run the program?
| a. | Prints: 0 |
| b. | Prints: 1 |
| c. | Compile-time error |
| d. | Run-time error |
| e. | None of the above |
class GFM17 {
int x; // 1
public static void main(String[] args) { // 2
int y = 0; // 3
System.out.print(x+","); // 4
System.out.print(y); // 5
}}
What is the result of attempting to compile and run the program?
| a. | Prints: 0,0 |
| b. | Compile-time error at line 1. |
| c. | Compile-time error at line 1. |
| d. | Compile-time error at line 2. |
| e. | Compile-time error at line 3. |
| f. | Compile-time error at line 4. |
| g. | Compile-time error at line 5. |
| h. | Run-time error |
| i. | None of the above |