Free Oracle 1Z1-803 Practice Test & Real Exam Questions
UESTION NO: 96 Which two statements are true for a two-dimensional array?
Correct Answer: C,D
Vote an answer
Given the for loop construct:
for ( expr1 ; expr2 ; expr3 ) {
statement;
}
Which two statements are true?
for ( expr1 ; expr2 ; expr3 ) {
statement;
}
Which two statements are true?
Correct Answer: B,D
Vote an answer
Explanation: Only visible for Pass4Leader members. You can sign-up / login (it's free).
Given:
public class TestLoop {
public static void main(String[] args) {
int array[] = {0, 1, 2, 3, 4};
int key = 3;
for (int pos = 0; pos < array.length; ++pos) {
if (array[pos] == key) {
break;
}
}
System.out.print("Found " + key + "at " + pos);
} }
What is the result?
public class TestLoop {
public static void main(String[] args) {
int array[] = {0, 1, 2, 3, 4};
int key = 3;
for (int pos = 0; pos < array.length; ++pos) {
if (array[pos] == key) {
break;
}
}
System.out.print("Found " + key + "at " + pos);
} }
What is the result?
Correct Answer: D
Vote an answer
Explanation: Only visible for Pass4Leader members. You can sign-up / login (it's free).
Given:

What is the result?

What is the result?
Correct Answer: C
Vote an answer
Explanation: Only visible for Pass4Leader members. You can sign-up / login (it's free).
Given the following code:

What will make this code compile and run?

What will make this code compile and run?
Correct Answer: E
Vote an answer
Explanation: Only visible for Pass4Leader members. You can sign-up / login (it's free).
Which two may precede the word 'class' in a class declaration?
Correct Answer: A,E
Vote an answer
Explanation: Only visible for Pass4Leader members. You can sign-up / login (it's free).
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");
}
void doStuff2() {
nt y = 7;
ystem.out.println("y");
or (int z = 0; z < 5; z++) {
ystem.out.println("z");
ystem.out.println("y");
}
Which two items are fields?
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");
}
void doStuff2() {
nt y = 7;
ystem.out.println("y");
or (int z = 0; z < 5; z++) {
ystem.out.println("z");
ystem.out.println("y");
}
Which two items are fields?
Correct Answer: A,C
Vote an answer
Given the following four Java file definitions:
// Foo.java
package facades;
public interface Foo { }
// Boo.java
package facades;
public interface Boo extends Foo { }
// Woofy.java
package org.domain
// line n1
public class Woofy implements Boo, Foo { }
// Test.java
package.org;
public class Test {
public static void main(String[] args) {
Foo obj=new Woofy();
Which set modifications enable the code to compile and run?
// Foo.java
package facades;
public interface Foo { }
// Boo.java
package facades;
public interface Boo extends Foo { }
// Woofy.java
package org.domain
// line n1
public class Woofy implements Boo, Foo { }
// Test.java
package.org;
public class Test {
public static void main(String[] args) {
Foo obj=new Woofy();
Which set modifications enable the code to compile and run?
Correct Answer: A
Vote an answer
Given: Given:
public class SuperTest {
public static void main(String[] args) { statement1 statement2 statement3
}
}
class Shape {
public Shape() {
System.out.println("Shape: constructor");
}
public void foo() {
System.out.println("Shape: foo");
}
}
class Square extends Shape {
public Square() {
super();
}
public Square(String label) {
System.out.println("Square: constructor");
}
public void foo() {
super.foo();
}
public void foo(String label) {
System.out.println("Square: foo");
}
}
}
}
What should statement1, statement2, and statement3, be respectively, in order to produce the result?
Shape: constructor
Square: foo
Shape: foo
public class SuperTest {
public static void main(String[] args) { statement1 statement2 statement3
}
}
class Shape {
public Shape() {
System.out.println("Shape: constructor");
}
public void foo() {
System.out.println("Shape: foo");
}
}
class Square extends Shape {
public Square() {
super();
}
public Square(String label) {
System.out.println("Square: constructor");
}
public void foo() {
super.foo();
}
public void foo(String label) {
System.out.println("Square: foo");
}
}
}
}
What should statement1, statement2, and statement3, be respectively, in order to produce the result?
Shape: constructor
Square: foo
Shape: foo
Correct Answer: D
Vote an answer
Given:

How many times is 2 printed as a part of the output?

How many times is 2 printed as a part of the output?
Correct Answer: B
Vote an answer
Given:
public class MyClass { public static void main(String[] args) { while (int ii = 0; ii < 2) { ii++;
System.out.println("ii = " + ii); } }
}
What is the result?
public class MyClass { public static void main(String[] args) { while (int ii = 0; ii < 2) { ii++;
System.out.println("ii = " + ii); } }
}
What is the result?
Correct Answer: D
Vote an answer
Explanation: Only visible for Pass4Leader members. You can sign-up / login (it's free).
Given the class definitions:

And the code fragment of the main() method,

What is the result?

And the code fragment of the main() method,

What is the result?
Correct Answer: B
Vote an answer
Given:

What code should be inserted?


What code should be inserted?

Correct Answer: A
Vote an answer
Explanation: Only visible for Pass4Leader members. You can sign-up / login (it's free).


