Oracle 1Z0-808 Questions and Answers

Page 1


WWW.DBexam.com

Java SE 8 Fundamentals Pearson VUE - Oracle 1Z0-808 Online Practice Exam

1


WWW.DBexam.com

We Will Provide You Latest Exam Question and Answers. 1) What is the character limit for a Single Line of Text field?

a) It is implemented as an array of the specified element type. b) Using a row by column convention, each row of a two-dimensional array must be of the same size. c) At declaration time, the number of elements of the array in each dimension must be specified. d) All methods of the class Object may be invoked on the two-dimensional array. Ans. A, D

2) Given: import java.util.ArrayList; import java.util.List; public class JavaSETest { public static void main(String[] args) { List<Integer> elements = new ArrayList<>(); elements.add(10); int firstElmnt = elements.get(1); System.out.println(firstElmnt); } } What is the result?

a) b) c) d)

null 10 0 An IndexOutOfBoundsException is thrown at runtime.

Ans. D

2


WWW.DBexam.com

3) Given: abstract class Writer { public static void write() { System.out.println("Writing..."); } } class Author extends Writer { public static void write() { System.out.println("Writing book"); } } public class Programmer extends Writer { public static void write() { System.out.println("Writing code"); } public static void main(String[] args) { Writer w = new Programmer(); w.write(); } } What is the result?

a) b) c) d)

Writing... Writing book Writing code Compilation fails.

Ans. A

4) Which access modifier makes a member available only to classes within the same package or subclasses? a) private b) protected c) public d) package-private

Ans. B 5) Given: class SuperClass { SuperClass(int x) { System.out.println("Super"); } } public class SubClass extends SuperClass { SubClass() {

3


WWW.DBexam.com

// Line n1 System.out.println("Sub 2"); } } Which statement, when inserted at Line n1, enables the code to compile?

a) b) c) d)

this(10); super(10); SuperClass(10); super.SuperClass (10);

Ans. B

6) Given the code fragment:

// Line n1 switch (cardVal) { case 4: case 5: case 6: case 7: case 8: System.out.println("Hit"); break; case 9: case 10: case 11: System.out.println("Double"); break; case 15: case 16: System.out.println("Surrender"); break; default: System.out.println("Stand"); } Which two code fragments can be inserted at Line n1, independently, enable to print Stand? a) int cardVal = 6; b) int cardVal = 10; c) int cardVal = 14; d) int cardVal = 18;

Ans. C, D

4


WWW.DBexam.com

7) Which of the following exception types must be handled or declared by the method in which they are thrown? a) NullPointerException b) Exception c) RuntimeException d) ArithmeticException

Ans. B 8) Given the code fragment: public class Test { public static void main(String[] args) { int x = 10; int y = 2; try { for (int z = 2; z >= 0; z--) { int ans = x / z; System.out.print(ans+ " "); } } catch (Exception e1) { System.out.println("E1"); } catch (ArithmeticException e1) { System.out.println("E2"); } } } What is the result? a) E1 b) E2 c) 5 10 E1 d) Compilation fails.

Ans. B 9) Given the code fragment: public class TestClass { public static void main(String[] args) { List<String> items = new ArrayList<>(); items.add("Pen"); items.add("Pencil"); items.add("Box"); for (String i : items) { if (i.indexOf("P") == 0) { continue; } else {

5


WWW.DBexam.com

System.out.print(i+" "); } } } } What is the result? a) Pen Pencil Box b) Pen Pencil c) Box d) Compilation fails.

Ans. C

10) Given the code fragment:

StringBuilder s1 = new StringBuilder("Java"); String s2 = "Love"; s1.append(s2); s1.substring(4); int foundAt = s1.indexOf(s2); System.out.println(foundAt); What is the result? a) -1 b) 3 c) 4 d) A StringIndexOutOfBoundsException is thrown at runtime.

Ans. C

VISIT WWW.DBEXAM.COM

6


Turn static files into dynamic content formats.

Create a flipbook
Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.