100% Correct of 1z0-808 testing engine materials and resource for Oracle certification for IT learners, Real Success Guaranteed with Updated 1z0-808 pdf dumps vce Materials. 100% PASS Java SE 8 Programmer I exam Today!
2021 Mar 1z0-808 torrent
Q31. Given:
What is the result?
A. 10:20
B. 0:20
C. Compilation fails at line n1
D. Compilation fails at line n2
Answer: D
Q32. Given the code fragment:
class Student {
int rollnumber;
String name;
List cources = new ArrayList();
// insert code here
public String toString() {
return rollnumber + " : " + name + " : " + cources;
}
}
And,
public class Test {
public static void main(String[] args) {
List cs = newArrayList();
cs.add("Java");
cs.add("C");
Student s = new Student(123,"Fred", cs);
System.out.println(s);
}
}
Which code fragment, when inserted at line // insert code here, enables class Test to print 123 : Fred : [Java, C]?
A.
private Student(int i, String name, List cs) {
/* initialization code goes here */
}
B.
public void Student(int i, String name, List cs) {
/* initialization code goes here */
}
C.
Student(int i, String name, List cs) {
/* initialization code goes here */
}
D.
Student(int i, String name, ArrayList cs) {
/* initialization code goes here */
}
Answer: C
Explanation:
Incorrect:
Not A: Student has private access line: Student s = new Student(123,"Fred", cs);
Not D: Cannot be applied to given types. Line: Student s = new Student(123,"Fred", cs);
Q33. Given:
What is the result?
A. box
B. nbo
C. bo
D. nb
E. An exception is thrown at runtime
Answer: E
Q34. Given:
public class TestOperator {
public static void main(String[] args) {
int result = 30 -12 / (2*5)+1;
System.out.print("Result = " + result);
}
}
What is the result?
A. Result = 2
B. Result = 3
C. Result = 28
D. Result = 29
E. Result = 30
Answer: E
Q35. Given:
What is the result?
A. The program prints nothing
B. d
C. A StringIndexOutOfBoundsException is thrown at runtime.
D. AnArrayIndexOutOfBoundsException is thrown at runtime.
E. A NullPointerException is thrown at runtime.
Answer: C
Abreast of the times 1z0-808 download:
Q36. Given the code fragment:
Which three lines fail to compile?
A. Line 7
B. Line 8
C. Line 9
D. Line 10
E. Line 11
F. Line 12
Answer: A,D,F
Q37. Given:
Which is true?
A. Sum for 0 to 0 = 55
B. Sum for 0 to 10 = 55
C. Compilation fails due to error on line 6.
D. Compilation fails due to error on line 7.
E. An Exception is thrown at the runtime.
Answer: D
Explanation:
Loop variables scope limited to that enclosing loop. So in this case, the scope of the loop variable x declared at line 5, limited to that for loop. Trying to access that variable at line 7, which is out of scope of the variable x, causes a compile time error. So compilation fails
due to error at line 7. Hence option D is correct.
Options A and B are incorrect, since code fails to compile.
Reference: httpsy/docs.oracle.com/javase/tutorial/java/nutsandbolts/variables.html
Q38. Given the code fragment:
A. Super Sub Sub
B. Contract Contract Super
C. Compilation fails at line n1
D. Compilation fails at line n2
Answer: D
Q39. Given the code in a file Traveler.java:
And the commands:
Javac Traveler.java
Java Traveler Java Duke What is the result?
A. Happy Journey! Duke
B. Happy Journey! Java
C. An exception is thrown at runtime
D. The program fails to execute due to a runtime error
Answer: D
Q40. Given:
What is the result?
A. int main 1
B. Object main 1
C. String main 1
D. Compilation fails
E. An exception is thrown at runtime
Answer: C