Ensurepass

QUESTION 101

Given the code fragments:

What is the result?

 A. Super Sub Sub B. Contract Contract Super C. Compilation fails at line n1 D. Compilation fails at line n2

QUESTION 102

Given the code fragment:

for (int ii = 0; ii < 3;ii++) {

int count = 0;

for (int jj = 3; jj > 0; jj–) {

if (ii == jj) {

++count;

break;

}

}

System.out.print(count);

continue;

}

What is the result?

 A. 011 B. 012 C. 123 D. 000

QUESTION 103

Given:

What is result?

 A. Successful B. Unsuccessful C. Compilation fails D. An exception is thrown at runtime

QUESTION 104

Given:

package p1;

public class Test {

static double dvalue;

static Test ref;

public static void main(String[] args) {

System.out.println(ref);

System.out.println(dvalue);

}

}

What is the result?

 A. 1 2 B. 0.000000 C. Null 0.0 D. Compilation fails E. A NullPointerException is thrown at runtime

QUESTION 105

Given:

public class Test {

public static void main(String[] args) {

try {

String[] arr =new String[4];

arr[1] = “Unix”;

arr[2] = “Linux”;

arr[3] = “Solarios”;

for (String var : arr) {

System.out.print(var + ” “);

}

} catch(Exception e) {

System.out.print (e.getClass());

}

}

}

What is the result?

 A. Unix Linux Solaris B. Null Unix Linux Solaris C. Class java.lang.Exception D. Class java.lang.NullPointerException

Explanation:

null Unix Linux Solarios

The first element, arr[0], has not been defined.

QUESTION 106

View the exhibit.

Given the code fragment:

Which change enables the code to print the following?

James age: 20

Williams age: 32

 A. Replacing line 5 with public static void main (String [] args) throws MissingInfoException, AgeOutofRangeException { B. Replacing line 5 with public static void main (String [] args) throws.Exception { C. Enclosing line 6 and line 7 within a try block and adding: catch(Exception e1) { //code goes here} catch (missingInfoExceptione2) { //code goes here} catch (AgeOutofRangeException e3) {//code goes here} D. Enclosing line 6 and line 7 within a try block and adding: catch (missingInfoException e2) { //code goes here} catch (AgeOutofRangeException e3) {//code goes here}

QUESTION 107

Which declaration initializes a boolean variable?

 A. boolean h = 1; B. boolean k = 0; C. boolean m = null; D. boolean j = (1 < 5);

Explanation:

The primitive type boolean has only two possible values: true and false. Here j is set to (1 <5), which evaluates to true.

QUESTION 108

Given the code fragment:

String name = “Spot”;

int age = 4;

String str =”My dog ” + name + ” is ” + age;

System.out.println(str);

And

StringBuilder sb = new StringBuilder();

Using StringBuilder, which code fragment is the best potion to build and print the following

string My dog Spot is 4

 A. sb.append(“My dog ” + name + ” is ” + age); System.out.println(sb); B. sb.insert(“My dog “).append( name + ” is ” + age); System.out.println(sb); C. sb.insert(“My dog “).insert( name ).insert(” is ” ).insert(age); System.out.println(sb); D. sb.append(“My dog “).append( name ).append(” is ” ).append(age); System.out.println(sb);

QUESTION 109

Given the code fragment:

 A. Super Sub Sub B. Contract Contract Super C. Compilation fails at line n1 D. Compilation fails at line n2

QUESTION 110

Given:

public class FieldInit {

char c;

booleanb;

float f;

void printAll() {

System.out.println(“c = ” + c);

System.out.println(“c = ” + b);

System.out.println(“c = ” + f);

}

public static void main(String[] args) {

FieldInit f = new FieldInit();

f.printAll();

}

}

What is the result?

 A. c = null b = false f = 0.0F B. c = 0 b = false f = 0.0f C. c = null b = true f = 0.0 D. c = b = false f = 0.0

Free VCE & PDF File for Oracle 1Z0-803 Real Exam

Instant Access to Free VCE Files: CompTIA | VMware | SAP …
Instant Access to Free PDF Files: CompTIA | VMware | SAP …