java se 8 programmer i 1z0 808 pdf (1 to 10)
Cause all that matters here is passing the Oracle 1z0 808 dumps pdf exam. Cause all that you need is a high score of java se 8 programmer i 1z0 808 pdf Java SE 8 Programmer I exam. The only one thing you need to do is downloading Examcollection exam 1z0 808 exam study guides now. We will not let you down with our money-back guarantee.
Q1. Given:
What is the result?
A. x: 1 y: 2
B. 3 y: 4
C. x: 0 y: 0
D. 3 y: 4
E. x: 1 y: 2
F. 0 y: 0
G. x: 0 y: 0
H. 0 y: 0
Answer: C
Q2. 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. message = Hi everyone!
B. message = Hi XvXryonX!
C. A compile time error is produced.
D. A runtime error is produced.
E. message =
F. message = Hi Xveryone!
Answer: B
Q3. Given:
What is the result?
A. 97 98 99 100 null null null
B. 91 98 99 100 101 102 103
C. Compilation rails.
D. A NullPointerException is thrown at runtime.
E. An ArraylndexOutOfBoundsException is thrown at runtime.
Answer: A
Q4. Which of the following exception will be thrown due to the statement given here?
int array[] = new int[-2];
A. NullPointerException
B. NegativeArraySizeException
C. ArrayIndexOutOfBoundsException
D. IndexOutOfBoundsException
E. This statement does not cause any exception.
Answer: B
Explanation:
In given statement we can see that, we have passed negative value for creating int array,
which results a NegativeArraySize Except ion. Hence option B is correct.
Option A is incorrect as it is thrown when an application attempts to use null in a case
where an object is required.
Option D is incorrect as IndexOutOfBoundsException thrown to indicate that an index of
some sort (such as to an array, to a string, or to a vector) is out of range.
REFERENCE
rhttpy/docs.oracle.com/iavase/S/docs/api/java/lang/NegativeArraySizeException.html
Q5. 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?
A. Replacing <code1> with index > 0 and replacing <code2> with index--;
B. Replacing <code1> with index > 0 and replacing <code2> with --index;
C. Replacing <code1> with index > 5 and replacing <code2> with --index ;
D. Replacing <code1> with index and replacing <code2> with --index ;
Answer: A
Explanation:
Note: Code in B (code2 is --index;). also works fine.
Q6. public class ForTest {
public static void main(String[] args) {
int[] arrar = {1,2,3};
for ( foo ) {
}
}
}
Which three are valid replacements for foo so that the program will compiled and run?
A. int i: array
B. int i = 0; i < 1; i++
C. ;;
D. ; i < 1; i++
E. ; i < 1;
Answer: A,B,C
Q7. Given:
A. ns = 50 S = 125 ns = 125 S = 125 ns = 100 S = 125
B. ns = 50 S = 125 ns = 125 S = 125 ns = 0 S = 125
C. ns = 50 S = 50 ns = 125 S = 125 ns = 100 S = 100
D. ns = 50 S = 50 ns = 125 S = 125 ns = 0 S = 125
Answer: B
Q8. Given:
Which inserted at line 11, will provide the following output?
[21, 15, 11]
A. list.removelf(e > e%2 != 0);
B. list.removelf(e -> e%2 != 0);
C. Ust.removelf(e -> e%2 = 0);
D. list.remove(e -> e%2 = 0);
E. None of the above.
Answer: C
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
Q9. Given the code fragment:
What is the result?
A. Match 1
B. Match 2
C. No Match
D. A NullPointerException is thrown at runtime.
Answer: B
Explanation:
it will compare the string contents of the StringBuilder with string object.
Q10. Given the code fragment:
StringBuilder sb = new StringBuilder ( ) ;
Sb.append (“world”);
Which code fragment prints Hello World?
A. sb.insert(0,"Hello ");
System.out.println(sb);
B. sb.append(0,"Hello ");
System.out.println(sb);
C. sb.add(0,"Hello ");
System.out.println(sb);
D. sb.set(0,"Hello ");
System.out.println(sb);D
Answer: A
Explanation: The java.lang.StringBuilder.insert(int offset, char c) method inserts the string representation of the char argument into this sequence. The second argument is inserted into the contents of this sequence at the position indicated by offset. The length of this sequence increases by one.The offset argument must be greater than or equal to 0, and less than or equal to the length of this sequence.
Reference: Java.lang.StringBuilder.insert() Method