Oracle 1Z0-808 Exam (page: 5)
Oracle Java SE 8 Programmer I
Updated on: 01-Sep-2025

Viewing Page 5 of 49

Given:

  1. Option A
  2. Option B
  3. Option C
  4. Option D

Answer(s): C



Given:



Which of the following is equivalent to the above code fragment?

  1. System.out.printLn(x>10?">, ': "<":, '=");
  2. System.out.println(x>10? ">"?"<":"=");
  3. System.out.println(x>10?">":x<10?"<":"=");
  4. System.out.printLn(x>10?">"?, '<"?"=");
  5. None of the above

Answer(s): B

Explanation:

Option A is incorrect as we can't use abstract with non abstract method, (here method has method body.)
Option C is incorrect as when overriding method we can't use more restrictive access
modifier, so trying to use private to override default access Level method causes a compile time error.
Option D is incorrect as default methods (not methods with default access level) are allowed only in interfaces.
Option E is incorrect as method all ready has void as return type, so we can't add int there. Option B is correct as we can use final there, since the method is non abstract https://docs.oracle.com/javase/tutorial/java/landl/polymorphism.html



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?

  1. Unix Linux Solaris
  2. Null Unix Linux Solaris
  3. Class java.lang.Exception
  4. Class java.lang.NullPointerException

Answer(s): B

Explanation:

null Unix Linux Solarios
The first element, arr[0], has not been defined.



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

  1. Square square = new Square ("bar");
    square.foo ("bar");
    square.foo();
  2. Square square = new Square ("bar");
    square.foo ("bar");
    square.foo ("bar");
  3. Square square = new Square ();
    square.foo ();
    square.foo(bar);
  4. Square square = new Square ();
    square.foo ();
    square.foo("bar");
  5. Square square = new Square ();
    square.foo ();
    square.foo ();
  6. Square square = new Square();
    square.foo("bar");
    square.foo();

Answer(s): F



Given the code fragment:
public class Test {
public static void main(String[] args) {
boolean isChecked = false;
int arry[] = {1, 3, 5, 7, 8, 9};
int index = arry.length;
while ( <code1> ) {
if (arry[index-1] % 2 ==0) {
isChecked = true;
}
<code2>
}
System.out.print(arry(index]+", "+isChecked));
}
}
Which set of changes enable the code to print 1, true?

  1. Replacing <code1> with index > 0 and replacing <code2> with index--;
  2. Replacing <code1> with index > 0 and replacing <code2> with --index;
  3. Replacing <code1> with index > 5 and replacing <code2> with --index ;
  4. Replacing <code1> with index and replacing <code2> with --index ;

Answer(s): A

Explanation:

Note: Code in B (code2 is --index;). also works fine.



Viewing Page 5 of 49



Share your comments for Oracle 1Z0-808 exam with other users:

Mchal 7/20/2023 3:38:00 AM

some questions are wrongly answered but its good nonetheless
POLAND


Merry 7/30/2023 6:57:00 AM

good questions
Anonymous