


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
1Z0-808 - Java SE 8 Programmer I sample questions
Typology: Study notes
1 / 4
This page cannot be seen from the preview
Don't miss anything!



Exam 808: Java SE 8
import java.util.ArrayList; import java.util.List;
public class JavaSETest { public static void main(String[] args) { List
What is the result?
A) null B) 10 C) 0 D) An IndexOutOfBoundsException is thrown at runtime.
// Line n 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;
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) Writing... B) Writing book C) Writing code D) Compilation fails.
class SuperClass { SuperClass(int x) { System.out.println("Super"); } }
public class SubClass extends SuperClass { SubClass() { // Line n System.out.println("Sub 2"); } }
Which statement, when inserted at Line n1, enables the code to compile?
A) this(10); B) super(10); C) SuperClass(10); D) super.SuperClass (10);
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) E B) E C) 5 10 E D) Compilation fails.
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) - B) 3 C) 4 D) A StringIndexOutOfBoundsException is thrown at runtime.