1Z0-808 Exam Questions
99 real 1Z0-808 exam questions with expert-verified answers and explanations. Page 1 of 2.
- Question #1
Given: interface Readable { public void readBook(); public void setBookMark(); } abstract class Book implements Readable { // line n1 public void readBook() { } // line n2 } class...
- Question #2
Given: public static void main(String[] args) { List<String> names = new ArrayList<>(); names.add("Robb"); names.add("Bran"); names.add("Rick"); names.add("Bran"); if (names.remove...
- Question #3
class A { public A(){ System.out.print ("A "); } } class B extends A{ public B(){ //line n1 System.out.print ("B "); } } class C extends B{ public C(){ //line n2 System.out.print (...
- Question #4
class X { static int i; int j; public static void main(String[] args) { X x1 = new X(); X x2 = new X(); x1.i = 3; x1.j = 4; x2.i = 5; x2.j = 6; System.out.println( "x1.i = " + x1.i...
- Question #5
Given the code fragment: 1. public class Test { 2. public static void main(String[] args) { 3. /* insert code here */ 4. array[0]=10; 5. array[1]=20; 6. System.out.print (array[0]+...
- Question #6
Given the code fragment: public class Test { public static void main(String[] args) { String[] arr = {"A", "B", "C", "D"}; for (int i = 0; i < arr.length; i++) { System.out.print (...
- Question #7
Given the code from the Greeting.java file: public class Greeting { public static void main(String[] args) { System.out.println("Hello " + args[0]); } } Which set of commands print...
- Question #8
Given: class Alpha { int ns; static int s; Alpha(int ns) { if (s < ns) { s = ns; this.ns = ns; } } void doPrint() { System.out.println("ns = " + ns + " s = " + s); } } And, public...
- Question #9
Given the code fragment: public class App { public static void main(String[] args) { String str1 = "Java"; String str2 = new String("Java"); //line n1 { System.out.println("Equal")...
- Question #10
Given: public class SumTest { public static void doSum(Integer x, Integer y) { System.out.println("Integer sum is " + (x + y)); } public static void doSum(double x, double y) { Sys...
- Question #11
Given the code fragment: String[] strs = new String[2]; int idx = 0; for (String s : strs) { strs[idx].concat(" element " + idx); idx++; } for (idx = 0; idx < strs.length; idx++) {...
- Question #12
Given: class Vehicle { int x; Vehicle() { this(10); // line n1 } Vehicle(int x) { this.x = x; } } class Car extends Vehicle { int y; Car() { super(); this(20); // line n2 } Car(int...
- Question #13
Given the definitions of the MyString class and the Test class: MyString.java: package p1; class MyString { String msg; MyString(String msg) { this.msg = msg; } } Test.java: packag...
- Question #14
Given the code fragment: 3. public static void main(String[] args) { 4. int iVar = 100; 5. float fVar = 100.100f; 6. double dVar = 123; 7. iVar = fVar; 8. fVar = iVar; 9. dVar = fV...
- Question #15
Given: MainTest.java: public class MainTest { public static void main(int[] args) { System.out.println("int main " + args[0]); } public static void main(Object[] args) { System.out...
- Question #16
Given the code fragment: int num[][] = new int[1][3]; for (int i = 0; i < num.length; i++) { for (int j = 0; j < num[i].length; j++) { num[i][j] = 10; } } Which option represents t...
- Question #17
Given the code fragment: public class Person { String name; int age = 25; public Person(String name) { //line n1 this(); setName(name); } public Person(String name, int age) { //li...
- Question #18
You are asked to develop a program for a shopping application, and you are given the following information: - The application must contain the classes Toy, EduToy, and ConsToy. - T...
- Question #19
int[] intArr = {15, 30, 45, 60, 75}; intArr[2] = intArr[4]; intArr[4] = 90; What are the values of each element in intArr after this code has executed?
- Question #20
Given the following array: int[] intArr = {8, 16, 32, 64, 128}; Which two code fragments, independently, print each element in this array?
- Question #21
Given the content of three files: A.java: public class A { public void a () {} int a; } B.java: public class B { private int doStuff() { private int x = 100; return x++; } } C.java...
- Question #22
Given the code fragment: int[] array = {1, 2, 3, 4, 5}; And given the requirements: 1. Process all the elements of the array in the order of entry. 2. Process all the elements of t...
- Question #23
public class TestScope { public static void main (String[] args) { int var1 = 200; System.out.print (doCalc(var1)); System.out.print ("+var1); } static int doCalc (int var1) { var1...
- Question #24
Given the following class declarations: - public abstract class Animal - public interface Hunter - public class Cat extends Animal implements Hunter - public class Tiger extends Ca...
- Question #25
Which statement is true about Java byte code?
- Question #26
Given: ```java public class MarkList { int num; public static void graceMarks(MarkList obj4) { obj4.num += 10; } public static void main(String[] args) { MarkList obj1 = new MarkLi...
- Question #27
Given: ```java public class Triangle { static double area; int b = 2, h = 3; public static void main(String[] args) { //line n1 double p, b, h; if (area == 0) { b = 3; h = 4; p = 0...
- Question #28
Given the code fragment: ```java public class Test { public static void main(String[] args) { //line n1 Switch (X) { case 1: System.out.println("One"); break; Case 2: System.out.pr...
- Question #29
Given: ```java public class App { public static void main(String[] args) { Boolean[] bool = new Boolean[2]; bool[0] = new Boolean(Boolean.parseBoolean("true")); bool[1] = new Boole...
- Question #30
Given the following code for the classes MyException and Test: ```java public class MyException extends RuntimeException {} public class Test { public static void main(String[] arg...
- Question #31
public class App { String myStr = "7007"; public void doStuff(String str) { int myNum = 0; try { String myStr = str; myNum = Integer.parseInt(myStr); } catch (NumberFormatException...
- Question #32
Which two are benefits of polymorphism?
- Question #33
int nums1[] = new int [3]; int nums2[] = {1, 2, 3, 4, 5}; nums1 = nums2; for (int x : nums1){ System.out.print (x + ":"); } What is the result?
- Question #34
public class Product { int id; String name; public Product (int id, String name) { this.id = id; this.name = name; } } And given the code fragment: 4. Product p1 = new Product (101...
- Question #35
Given the following classes: public class Employee { public int salary; } public class Manager extends Employee { public int budget; } public class Director extends Manager { publi...
- Question #36
class Product { double price; } public class Test { public static void updatePrice (Product product, double price) { product.price = price; price = 2; product.price = product.price...
- Question #37
if (@Var++ < 10) { System.out.println (@Var + " Hello World!"); } else { System.out.println (@Var + " Hello Universe!"); } What is the result if the integer aVar is 9?
- Question #38
public static void main(String[] args) { String date = "2014-05-04"; .parse("2014-05-04T00:00:00.000"); .format(DateTimeFormatter.ISO_DATE_TIME); System.out.println(date); } What i...
- Question #39
public static void main(String[] args) { Short s1 = 200; Integer s2 = 400; long s3 = (long) (s1 + s2); //line n1 String s4 = (String) (s3 * s2); //line n2 System.out.println("Sum i...
- Question #40
What is the name of the Java concept that uses access modifiers to protect variables and hide them within a class?
- Question #41
Given the code fragment: ```java abstract class Planet { protected void revolve() { //line n1 } } abstract void rotate(); class Earth extends Planet { void revolve() { //line n3 }...
- Question #42
Given: ```java class Vehicle { String type = "4W"; int maxSpeed = 100; Vehicle(String type, int maxSpeed) { this.type = type; this.maxSpeed = maxSpeed; } } class Car extends Vehicl...
- Question #43
Given the code fragment: ```java 1. class X { 2. public void printFileContent () { 3. /* code goes here */ 4. throw new IOException(); 5. } 6. } 7. public class Test { 8. public st...
- Question #44
Given the following two classes: ```java public class Customer { ElectricAccount acct = new ElectricAccount(); public void useElectricity(double kWh) { acct.addKwh(kWh); } } public...
- Question #45
Person.java: public class Person { String name; int age; public Person(String n, int a) { name = n; age = a; } public String getName() { return name; } public int getAge() { return...
- Question #46
public static void main(String[] args) { String[][] arr = {{"A", "B", "C"}, {"D", "E"}}; for (int i = 0; i < arr.length; i++) { for (int j = 0; j < arr[i].length; j++) { System.out...
- Question #47
QUESTION 58 Given the code fragment: public static void main(String[] args) { String str = " "; str.trim(); System.out.println(str.equals("") + " " + str.isEmpty()); } What is the...
- Question #48
class CD { int r; CD(int r) { this.r=r; } } class DVD extends CD { int c; DVD(int r, int c) { // line n1 } } And given the code fragment: DVD dvd = new DVD(10, 20); Which code frag...
- Question #49
QUESTION 60 Given the code fragment: int a[] = {1, 2, 3, 4, 5}; for (XXXX) { System.out.print (a[e]); } Which option can replace xxxx to enable the code to print 135?
- Question #50
QUESTION 61 Which statement best describes encapsulation?