Skip to main content

1Z0-808 Real Exam Questions

Java SE 8 Programmer I

385 questions available · Page 1 of 39

Updated Exam DumpsVerified AnswersPass Guarantee

Get Complete Exam Dumps
Question 1 Single choice

Consider following method

Which statement is true?

  1. A

    This method is invalid.

  2. B

    This method can be used only in an interface.

  3. C

    This method can return anything.

  4. D

    This method can be used only in an interface or an abstract class.

  5. E

    None of above.

Show answer and explanation

Correct answer: B

Explanation

Given method is declared as default method so we can use it only inside an interface. Hence option B is correct and
option D is incorrect.
Option A is incorrect as it is valid method.
Option C is incorrect as return type is void, which means we can't return anything.

Question 2 Single choice

Which statement is true about the default constructor of a top-level class?

  1. A

    It can take arguments.

  2. B

    It has private access modifier in its declaration.

  3. C

    It can be overloaded.

  4. D

    The default constructor of a subclass always invokes the no-argument constructor of its superclass.

Show answer and explanation

Correct answer: D

Explanation

Explanation: In both Java and C#, a "default constructor" refers to a nullary constructor that is automatically generated by the compiler if no constructors have been defined for the class. The default constructor is also empty, meaning that it does nothing. A programmer-defined constructor that takes no parameters is also called a default constructor.

Question 3 Single choice

A method is declared to take three arguments. A program calls this method and passes only two arguments.

What is the results?

  1. A

    Compilation fails.

  2. B

    The third argument is given the value null.

  3. C

    The third argument is given the value void.

  4. D

    The third argument is given the value zero.

  5. E

    The third argument is given the appropriate falsy value for its declared type.

  6. F

    An exception occurs
    when the method attempts to access the third argument.

Show answer and explanation

Correct answer: A

Question 4 Single choice

Given the code fragment:

StringBuilder sb = new StringBuilder ( ) ;

Sb.append ("world");

Which code fragment prints Hello World?

  1. A

    sb.insert(0,"Hello ");
    System.out.println(sb);

  2. B

    sb.append(0,"Hello ");
    System.out.println(sb);

  3. C

    sb.add(0,"Hello ");
    System.out.println(sb);

  4. D

    sb.set(0,"Hello ");
    System.out.println(sb);D

Show answer and explanation

Correct answer: A

Explanation

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.

References:
Java.lang.StringBuilder.insert() Method

Question 5 Single choice

Given:

What is the result?

  1. A

    2 4 6 8 10 12

  2. B

    2 4 6 8 10 12 14

  3. C

    Compilation fails

  4. D

    The program prints multiple of 2 infinite times

  5. E

    The program prints nothing

Show answer and explanation

Correct answer: B

Question 6 Single choice

Given:

What is the result?

  1. A

    c=
    b = false
    f = 0.0

  2. B

    c = null
    b = true
    f = 0.0

  3. C

    c = 0
    b = false
    f = 0.0f

  4. D

    c = null
    b = false
    f = 0.0F

Show answer and explanation

Correct answer: A

Question 7 Single choice

Given:

What is the output?

  1. A

    2015-03-27

  2. B

    2015-04-27

  3. C

    2015-02-27

  4. D

    Compilation fails due to error at line 6.

  5. E

    Compilation fails due to error at line 8.

Show answer and explanation

Correct answer: A

Explanation

To create we have used following method with LocalDate class; public static LocalDate of(intyear, int month, int dayOfMonth) Here we need to remember that month is not zero based so if you pass 1 for month, then month will be January.
Then we have used period object of 1 day and add to date object which makes current date to next day, so final output is 2015-03-27. Hence option A is correct.
https://docs.oracle.com/javase/tutorial/datetime/iso/
datetime.html

Question 8 Single choice

Given:

What is the result?

  1. A

    Welcome Visit Count:0
    Welcome Visit Count: 1

  2. B

    Compilation fails at line n2.

  3. C

    Compilation fails at line n1.

  4. D

    Welcome Visit Count:0
    Welcome Visit Count: 0

Show answer and explanation

Correct answer: C

Explanation
Question 9 Single choice

Given:

What is the result?

  1. A

    Initialized
    Started

  2. B

    Initialized
    Started
    Initialized

  3. C

    Compilation fails

  4. D

    An exception is thrown at runtime

Show answer and explanation

Correct answer: B

Question 10 Single choice

Given the code fragment:

What is the result?

  1. A

    2 4

  2. B

    0 2 4 6

  3. C

    0 2 4

  4. D

    Compilation fails

Show answer and explanation

Correct answer: C