Oracle Java SE 7 Programmer I (1Z1-803) Free Practice Test
Question 1
public class Two {
public static void main(String[] args) {
try {
doStuff();
system.out.println("1");
}
catch {
system.out.println("2");
}}
public static void do Stuff() {
if (Math.random() > 0.5) throw new RunTimeException(); doMoreStuff();
System.out.println("3 ");
}
public static void doMoreStuff() {
System.out.println("4");
}
}
Which two are possible outputs?
public static void main(String[] args) {
try {
doStuff();
system.out.println("1");
}
catch {
system.out.println("2");
}}
public static void do Stuff() {
if (Math.random() > 0.5) throw new RunTimeException(); doMoreStuff();
System.out.println("3 ");
}
public static void doMoreStuff() {
System.out.println("4");
}
}
Which two are possible outputs?
Correct Answer: B,D
Explanation: Only visible for TestSimulate members. You can sign-up / login (it's free).
Question 2
Given the code fragment:

What is the result?

What is the result?
Correct Answer: C
Question 3
Given: What is the result?


Correct Answer: E
Question 4
Given the code fragment:

Which statement is true?

Which statement is true?
Correct Answer: B
Question 5
Given the code fragment:


Correct Answer: A
Question 6
Given the code fragment:
public class Test {
static String[][] arr =new String[3][];
private static void doPrint() {
//insert code here }
public static void main(String[] args) {
String[] class1 = {"A","B","C"};
String[] class2 = {"L","M","N","O"};
String[] class3 = {"I","J"};
arr[0] = class1;
arr[1] = class2;
arr[2] = class3;
Test.doPrint();
}
}
Which code fragment, when inserted at line //insert code here, enables the code to print COJ?
public class Test {
static String[][] arr =new String[3][];
private static void doPrint() {
//insert code here }
public static void main(String[] args) {
String[] class1 = {"A","B","C"};
String[] class2 = {"L","M","N","O"};
String[] class3 = {"I","J"};
arr[0] = class1;
arr[1] = class2;
arr[2] = class3;
Test.doPrint();
}
}
Which code fragment, when inserted at line //insert code here, enables the code to print COJ?
Correct Answer: C
Explanation: Only visible for TestSimulate members. You can sign-up / login (it's free).
Question 7
Given:

What is the result?

What is the result?
Correct Answer: A
Question 8
Given: What is the result?


Correct Answer: D
Question 9
Given:
public class Marklist {
int num;
public static void graceMarks(Marklist obj4) {
obj4.num += 10;
}
public static void main(String[] args) {
MarkList obj1 = new MarkList();
MarkList obj2 = obj1;
MarkList obj1 = null;
obj2.num = 60;
graceMarks(obj2);
}
}
How many objects are created in the memory runtime?
public class Marklist {
int num;
public static void graceMarks(Marklist obj4) {
obj4.num += 10;
}
public static void main(String[] args) {
MarkList obj1 = new MarkList();
MarkList obj2 = obj1;
MarkList obj1 = null;
obj2.num = 60;
graceMarks(obj2);
}
}
How many objects are created in the memory runtime?
Correct Answer: C
Explanation: Only visible for TestSimulate members. You can sign-up / login (it's free).
Question 10
Given:

This class is poorly encapsulated. You need to change the circle class to compute and return the area instead.
What three modifications are necessary to ensure that the class is being properly encapsulated?

This class is poorly encapsulated. You need to change the circle class to compute and return the area instead.
What three modifications are necessary to ensure that the class is being properly encapsulated?
Correct Answer: A,B,D
Question 11
Given:
public class Test1 {
static void doubling (Integer ref, int pv) {
ref =20;
pv = 20;
}
public static void main(String[] args) {
Integer iObj = new Integer(10);
int iVar = 10;
doubling(iObj++, iVar++);
System.out.println(iObj+ ", "+iVar);
What is the result?
public class Test1 {
static void doubling (Integer ref, int pv) {
ref =20;
pv = 20;
}
public static void main(String[] args) {
Integer iObj = new Integer(10);
int iVar = 10;
doubling(iObj++, iVar++);
System.out.println(iObj+ ", "+iVar);
What is the result?
Correct Answer: D
Explanation: Only visible for TestSimulate members. You can sign-up / login (it's free).
Question 12
Given:
public class Test { public static void main(String[] args) { int ax = 10, az = 30; int aw = 1, ay = 1; try { aw = ax % 2; ay = az / aw; } catch (ArithmeticException e1) { System.out.println("Invalid Divisor"); } catch (Exception e2) { aw = 1; System.out.println("Divisor Changed"); } ay = az /aw; // Line 14 System.out.println("Succesful Division " + ay);
}
}
What is the result?
public class Test { public static void main(String[] args) { int ax = 10, az = 30; int aw = 1, ay = 1; try { aw = ax % 2; ay = az / aw; } catch (ArithmeticException e1) { System.out.println("Invalid Divisor"); } catch (Exception e2) { aw = 1; System.out.println("Divisor Changed"); } ay = az /aw; // Line 14 System.out.println("Succesful Division " + ay);
}
}
What is the result?
Correct Answer: D