1z0-808 Java SE 8 Programmer I (OCA) Practice Questions
Prepare for 1z0-808 with more than an answer.
- Level
- Associate
- Valid for
- Does not expire
Domains covered on the exam 9
- Java Basics11%
- Working With Java Data Types14%
- Using Operators and Decision Constructs13%
- Creating and Using Arrays8%
- Using Loop Constructs9%
- Working with Methods and Encapsulation15%
- Working with Inheritance14%
- Handling Exceptions9%
- Working with Selected classes from the Java API17%
- 1
Given the code fragment, and given the requirements:
If the value of the qty variable is greater than or equal to 90, discount = 0.5
If the value of the qty variable is between 80 and 90, discount = 0.2Which two code (A to E) fragments can be independently placed at line n1 to meet the requirements? (Choose two.)

Show answer details
Correct answer: A, C
This is one of the correct answers in a multi-select question. The selected options work together to satisfy the Java programming requirements, demonstrating proper syntax, valid type usage, correct method implementation, or appropriate design patterns. Each correct choice represents a valid solution component that addresses different aspects of the programming scenario while maintaining Java language compliance and best practices.
This is one of the correct answers in a multi-select question. The selected options work together to satisfy the Java programming requirements, demonstrating proper syntax, valid type usage, correct method implementation, or appropriate design patterns. Each correct choice represents a valid solution component that addresses different aspects of the programming scenario while maintaining Java language compliance and best practices.
- 2
Given the code fragment, what is the result?

Show answer details
Correct answer: B
This is one of the correct answers in a multi-select question. The selected options work together to satisfy the Java programming requirements, demonstrating proper syntax, valid type usage, correct method implementation, or appropriate design patterns. Each correct choice represents a valid solution component that addresses different aspects of the programming scenario while maintaining Java language compliance and best practices.
- 3
Given the code fragment below, which option, inserted at line n1, prints The Top element: 30?

Show answer details
Correct answer: E
This is one of the correct answers in a multi-select question. The selected options work together to satisfy the Java programming requirements, demonstrating proper syntax, valid type usage, correct method implementation, or appropriate design patterns. Each correct choice represents a valid solution component that addresses different aspects of the programming scenario while maintaining Java language compliance and best practices.
- 4
Given the code snippet from a compiled Java source file, and the output below it:
Which command should you run to obtain this output?

Show answer details
Correct answer: C
This is one of the correct answers in a multi-select question. The selected options work together to satisfy the Java programming requirements, demonstrating proper syntax, valid type usage, correct method implementation, or appropriate design patterns. Each correct choice represents a valid solution component that addresses different aspects of the programming scenario while maintaining Java language compliance and best practices.
- 5
A system processes different types of media files. A base class
MediaFilehas a methodvoid process() throws IOException. A subclassVideoFileoverrides this method. According to Java's rules for overriding methods with checked exceptions, which of the following declarations for theprocessmethod inVideoFileare valid? (Select ALL that apply)classDiagram class MediaFile { +process() throws IOException } class VideoFile { +process() } MediaFile <|-- VideoFileShow answer details
Correct answer: A, B, E
This is valid. An overriding method can declare a subclass of a checked exception declared by the superclass method.
FileNotFoundExceptionis a subclass ofIOException.This is valid. An overriding method can choose not to declare any checked exceptions, even if the superclass method does.
This is valid. An overriding method can declare any unchecked (runtime) exceptions regardless of what the superclass method declares, because they do not need to be handled at compile time.
- 6
Given the following:

Show answer details
Correct answer: D
This is one of the correct answers in a multi-select question. The selected options work together to satisfy the Java programming requirements, demonstrating proper syntax, valid type usage, correct method implementation, or appropriate design patterns. Each correct choice represents a valid solution component that addresses different aspects of the programming scenario while maintaining Java language compliance and best practices.
- 7
Given the code fragments below, which statement is true?

Show answer details
Correct answer: C
This is one of the correct answers in a multi-select question. The selected options work together to satisfy the Java programming requirements, demonstrating proper syntax, valid type usage, correct method implementation, or appropriate design patterns. Each correct choice represents a valid solution component that addresses different aspects of the programming scenario while maintaining Java language compliance and best practices.
- 8
Given the code fragment, what is the result?

Show answer details
Correct answer: B
This is one of the correct answers in a multi-select question. The selected options work together to satisfy the Java programming requirements, demonstrating proper syntax, valid type usage, correct method implementation, or appropriate design patterns. Each correct choice represents a valid solution component that addresses different aspects of the programming scenario while maintaining Java language compliance and best practices.
- 9
Given the code fragment, what is the result?

Show answer details
Correct answer: D
Compilation fails due to violations of Java language rules such as incorrect syntax, type mismatches, missing declarations, or invalid operations. The compiler performs static analysis and identifies errors that would prevent the program from executing correctly, requiring fixes before the code can be successfully compiled into bytecode.
- 10
Which statement is true about the main() method?
Show answer details
Correct answer: A
This is one of the correct answers in a multi-select question. The selected options work together to satisfy the Java programming requirements, demonstrating proper syntax, valid type usage, correct method implementation, or appropriate design patterns. Each correct choice represents a valid solution component that addresses different aspects of the programming scenario while maintaining Java language compliance and best practices.





