1Z0-803 Dumps

1Z0-803 Free Practice Test

Oracle 1Z0-803: Java SE 7 Programmer I

QUESTION 16

Given:
public class String1 {
public static void main(String[] args) { String s = "123";
if (s.length() >2)

Correct Answer: B
123xxx
The if clause is not applied. Note: Syntax of if-statement:
if ( Statement ) {
}

QUESTION 17

Given:

Correct Answer: B

QUESTION 18

Given:
public class ScopeTest { int j, int k;
public static void main(String[] args) { ew ScopeTest().doStuff(); }
void doStuff() { nt x = 5; oStuff2();
System.out.println("x");
}
voiddoStuff2() { nt y = 7;
ystem.out.println("y");
or (int z = 0; z < 5>ystem.out.println("y");
}
Which two items are fields?

Correct Answer: AB

QUESTION 19

Given the code fragment:
int a = 0; a++;
System.out.printIn(a++); System.out.printIn(a);
What is the result?

Correct Answer: A
The first println prints variable a with value 1 and then increases the variable to 2.

QUESTION 20

Given:
public class Main {
public static void main(String[] args) { try {
doSomething();
}
catch (SpecialException e) { System.out.println(e);
}}
static void doSomething() { int [] ages = new int[4]; ages[4] = 17; doSomethingElse();
}
static void doSomethingElse() {
throw new SpecialException("Thrown at end of doSomething() method"); }
}
What is the output?

Correct Answer: C
The following line causes a runtime exception (as the index is out of bounds): ages[4] = 17;
A runtime exception is thrown as anArrayIndexOutOfBoundsException.
Note: The third kind of exception (compared to checked exceptions and errors) is the runtime exception. These are exceptional conditions that are internal to the application, and
that the application usually cannot anticipate or recover from. These usually indicate programming bugs, such as logic errorsor improper use of an API.
Runtime exceptionsare not subjectto the Catch or Specify Requirement. Runtime exceptions are those indicated byRuntimeExceptionand its subclasses.