[Dec 28, 2024] Oracle 1z0-808 Real Exam Questions and Answers FREE [Q178-Q201]

Share

[Dec 28, 2024] Oracle 1z0-808 Real Exam Questions and Answers FREE

Pass Oracle 1z0-808 Exam Info and Free Practice Test

NEW QUESTION # 178
Given the following classes:

Which two options fail to compile when placed at line n1 of the main method?

  • A. employee.budget = 200_000;
  • B. employee.salary = 50_000;
  • C. manager.budget = 1_000_000;
  • D. director.salary = 80_000;
  • E. manager.stockOption = 500;
  • F. director.stockOptions = 1_000;

Answer: A,E


NEW QUESTION # 179
Given the following code for the classes MyException and Test:

What is the result?

  • A. A
  • B. B
  • C. Either A or B
  • D. A B
  • E. A compile time error occurs at line n1

Answer: B


NEW QUESTION # 180
Given the code fragment:

Which three code fragments can be independently inserted at line n1 to enable the code to print one?
(Choose three.)

  • A. Long x = 1;
  • B. Byte x = 1;
  • C. Double x = 1;
  • D. String x = "1";
  • E. short x = 1;
  • F. Integer x = new Integer ("1");

Answer: B,E,F


NEW QUESTION # 181
Given the following code:

What is the output?

  • A. 5 4
  • B. 3 5
  • C. 4 7
  • D. 4 4
  • E. 4 5
  • F. 4 21

Answer: E


NEW QUESTION # 182
Given the following two classes:

How should you write methods in the ElectricAccount class at line n1 so that the member variable bill is always equal to the value of the member variable kwh multiplied by the member variable rate?
Any amount of electricity used by a customer (represented by an instance of the customer class) must contribute to the customer's bill (represented by the member variable bill) through the method use Electricity method. An instance of the customer class should never be able to tamper with or decrease the value of the member variable bill.

  • A. Option B
  • B. Option D
  • C. Option A
  • D. Option C

Answer: C,D


NEW QUESTION # 183
Given the code fragment:

What could expression1 and expression2 be, respectively, in order to produce output ?, 16?

  • A. A + +, b - -
  • B. + +a, - -b
  • C. + +a, b- -
  • D. A+ +, - - b

Answer: C


NEW QUESTION # 184
public class StringReplace {
public static void main(String[] args) {
String message = "Hi everyone!";
System.out.println("message = " + message.replace("e", "X")); }
}
What is the result?

  • A. A runtime error is produced.
  • B. A compile time error is produced.
  • C. message = Hi everyone!
  • D. message =
  • E. message = Hi Xveryone!
  • F. message = Hi XvXryonX!

Answer: F


NEW QUESTION # 185
Given the code fragment:

Which three lines fail to compile?

  • A. Line 10
  • B. Line 9
  • C. Line 7
  • D. Line 11
  • E. Line 8
  • F. Line 12

Answer: A,C,F


NEW QUESTION # 186
Given: Which inserted at line 11, will provide the following output?

[21, 15, 11]

  • A. Ust.removelf(e -> e%2 = 0);
  • B. list.removelf(e -> e%2 != 0);
  • C. list.remove(e -> e%2 = 0);
  • D. list.removelf(e > e%2 != 0);
  • E. None of the above.

Answer: A

Explanation:
In output we can see that only odd numbers present, so we need to remove only even numbers to get expected output. From Java SE 8, there is new method call removelf which takes predicate object and remove elements which satisfies predicate condition. Predicate has functional method call take object and check if the given condition met or not, if met it returns true, otherwise false. Option C we have passed correct lambda expression to check whether the number is odd or even that matches to the functional method of predicate interface. Option A is incorrect as it is invalid lambda expression. Option B is incorrect as it removes all odd numbers. Option D is incorrect as there is no remove method that takes predicate as argument.
https://docs.oracle.eom/javase/8/docs/api/java/util/ArrayList.html


NEW QUESTION # 187
Given the code fragment:
int b = 3; if ( !(b > 3)) {
System.out.println("square ");
}{
System.out.println("circle ");
}
System.out.println("...");
What is the result?

  • A. Compilation fails.
  • B. square...
  • C. squarecircle...
  • D. circle...

Answer: C


NEW QUESTION # 188
Which three statements describe the object-oriented features of the Java language?

  • A. A main method must be declared in every class.
  • B. A package must contain more than one class.
  • C. Objects can share behaviors with other objects.
  • D. Objects cannot be reused.
  • E. A subclass can inherit from a superclass.
  • F. Object is the root class of all other objects.

Answer: A,C,E

Explanation:
Reference: http://www.javaworld.com/article/2075459/java-platform/java-101--object-orientedlanguage-basics--part-5--object-and-its-methods.html (see the sub title, Object is root of all classes not all other objects)


NEW QUESTION # 189
Given:

And given the code fragment:

What is the result?

  • A. 300:300200:300
  • B. 200:300200:300
  • C. 300:100200:300
  • D. 300:00:300

Answer: C


NEW QUESTION # 190
Given:

What is the result?

  • A. 3 4 3 6
  • B. 5 4 5 6
  • C. 3 4 5 6
  • D. 3 6 4 6

Answer: B


NEW QUESTION # 191
Given:

What is the result?

  • A. 10 : 22 : 22
  • B. 10 : 30 : 6
  • C. 10 : 22 : 20
  • D. 10 : 22 : 6

Answer: B


NEW QUESTION # 192
Given:

And given the commands:

What is the result?

  • A. 1 null
  • B. true true
  • C. true false
  • D. A ClassCastException is thrown at runtime.
  • E. false false

Answer: B


NEW QUESTION # 193
Given:

Which code fragment can replace the if block?

  • A. Option B
  • B. Option A
  • C. Option C
  • D. Option D

Answer: D


NEW QUESTION # 194
Given the code fragment:

What is the result?

  • A. 2012-02-11
  • B. 2012-02-10
  • C. Compilation fails
  • D. A DateTimeException is thrown at runtime.

Answer: C


NEW QUESTION # 195
Given the code fragment:

Which two code fragments can be independently inserted at line n1 to enable the code to print the elements of the array in reverse order? (Choose two.) A:

B:

C:

D:

E:

  • A. Option B
  • B. Option D
  • C. Option A
  • D. Option C
  • E. Option E

Answer: C,E


NEW QUESTION # 196
Given:

What is the result?

  • A. 97 98
    99 100 null null null
  • B. Compilation rails.
  • C. A NullPointerException is thrown at runtime.
  • D. An ArraylndexOutOfBoundsException is thrown at runtime.
  • E. 97 98
    99 100 101 102 103

Answer: A


NEW QUESTION # 197
Given this class:

Which two changes would encapsulate this class and ensure that the area field is always equal to length * heightwhenever the Rectangle class is used?

  • A. Call the setArea method at the end of the setHeight method.
  • B. Call the setArea method at the beginning of the setHeight method.
  • C. Change the setArea method to private.
  • D. Change the area field to public.
  • E. Call the setArea method at the beginning of the setLength method.
  • F. Call the setArea method at the end of the setLength method.

Answer: A,C


NEW QUESTION # 198
Given the code fragment:

Which code fragment, when inserted at line n1, enables the App class to print Equal?

  • A. Option B
  • B. Option D
  • C. Option A
  • D. Option C

Answer: C


NEW QUESTION # 199
Given the code fragments:

And:

Which statement is true?

  • A. After line 11, one object is eligible for garbage collection.
  • B. After line 11, none of the objects are eligible for garbage collection.
  • C. After line 11, three objects are eligible for garbage collection.
  • D. After line 11, two objects are eligible for garbage collection.

Answer: C


NEW QUESTION # 200
Given:
public class Test {
public static void main(String[] args) {
int day = 1;
switch (day) {
case "7": System.out.print("Uranus");
case "6": System.out.print("Saturn");
case "1": System.out.print("Mercury");
case "2": System.out.print("Venus");
case "3": System.out.print("Earth");
case "4": System.out.print("Mars");
case "5": System.out.print("Jupiter");
}
}
}
Which two modifications, made independently, enable the code to compile and run?

  • A. Adding a break statement after each print statement
  • B. Adding a default section within the switch code-block
  • C. Arranging the case labels in ascending order
  • D. Changing the type of the variable day to String
  • E. Changing the string literals in each case label to integer

Answer: A,E

Explanation:
The following will work fine:
public class Test {
public static void main(String[] args) {
int day = 1;
switch (day) {
case 7: System.out.print("Uranus"); break;
case 6: System.out.print("Saturn"); break;
case 1: System.out.print("Mercury"); break;
case 2: System.out.print("Venus"); break;
case 3: System.out.print("Earth"); break;
case 4: System.out.print("Mars"); break;
case 5: System.out.print("Jupiter"); break;
}
}
}


NEW QUESTION # 201
......

Latest 1z0-808 Exam Dumps Oracle Exam: https://actual4test.exam4labs.com/1z0-808-practice-torrent.html