Oracle Java SE 7 Programmer I - 1Z1-803 Exam Practice Test
Given:
public class TestLoop1 { public static void main(String[] args) { int a = 0, z=10; while (a < z) { a++;
--z;
}
System.out.print(a + " : " + z);
}
}
What is the result?
public class TestLoop1 { public static void main(String[] args) { int a = 0, z=10; while (a < z) { a++;
--z;
}
System.out.print(a + " : " + z);
}
}
What is the result?
Correct Answer: A
Explanation: Only visible for ExamsLabs members. You can sign-up / login (it's free).
Identify two benefits of using ArrayList over array in software development.
Correct Answer: C,D
Explanation: Only visible for ExamsLabs members. You can sign-up / login (it's free).
Which two are Java Exception classes?
Correct Answer: B,C
Given the code fragment:
Int [] [] array = {{0}, {0, 1}, {0, 2, 4}, {0, 3, 6, 9}, {0, 4, 8, 12, 16}};
Systemout.printIn(array [4] [1]);
System.out.printIn (array) [1] [4]);
What is the result?
Int [] [] array = {{0}, {0, 1}, {0, 2, 4}, {0, 3, 6, 9}, {0, 4, 8, 12, 16}};
Systemout.printIn(array [4] [1]);
System.out.printIn (array) [1] [4]);
What is the result?
Correct Answer: D
Explanation: Only visible for ExamsLabs members. You can sign-up / login (it's free).
Given the code fragment:

What values of x, y, z will produce the following result?
1 2 3 4
1 2 3 4
1 2 3 4
1 2 3 4

What values of x, y, z will produce the following result?
1 2 3 4
1 2 3 4
1 2 3 4
1 2 3 4
Correct Answer: B
Explanation: Only visible for ExamsLabs members. You can sign-up / login (it's free).
Which two actions will improve the encapsulation of a class?
Correct Answer: B,D
Explanation: Only visible for ExamsLabs members. You can sign-up / login (it's free).
Given:
class Base {
public static void main(String[] args) {
System.out.println("Base " + args[2]);
}
}
public class Sub extends Base{
public static void main(String[] args) {
System.out.println("Overriden " + args[1]);
}
}
And the commands:
javac Sub.java
java Sub 10 20 30
What is the result?
class Base {
public static void main(String[] args) {
System.out.println("Base " + args[2]);
}
}
public class Sub extends Base{
public static void main(String[] args) {
System.out.println("Overriden " + args[1]);
}
}
And the commands:
javac Sub.java
java Sub 10 20 30
What is the result?
Correct Answer: B
View the Exhibit.
public class Hat {
public int ID =0;
public String name = "hat";
public String size = "One Size Fit All";
public String color="";
public String getName() { return name; }
public void setName(String name) {
this.name = name;
}
}
Given
public class TestHat {
public static void main(String[] args) {
Hat blackCowboyHat = new Hat();
}
}
Which statement sets the name of the Hat instance?
public class Hat {
public int ID =0;
public String name = "hat";
public String size = "One Size Fit All";
public String color="";
public String getName() { return name; }
public void setName(String name) {
this.name = name;
}
}
Given
public class TestHat {
public static void main(String[] args) {
Hat blackCowboyHat = new Hat();
}
}
Which statement sets the name of the Hat instance?
Correct Answer: B
Given:
public class Painting {
private String type;
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public static void main(String[] args) {
Painting obj1 = new Painting();
Painting obj2 = new Painting();
obj1.setType(null);
obj2.setType("Fresco");
System.out.print(obj1.getType() + " : " + obj2.getType());
}
}
What is the result?
public class Painting {
private String type;
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public static void main(String[] args) {
Painting obj1 = new Painting();
Painting obj2 = new Painting();
obj1.setType(null);
obj2.setType("Fresco");
System.out.print(obj1.getType() + " : " + obj2.getType());
}
}
What is the result?
Correct Answer: A