Loading provider exams...
1Z0-808: Java SE 8 Programmer I Practice Exam — Free Online Test
About the Exam Oracle positions this as the entry-level Java SE 8 exam for candidates who are new to Java or building foundational Java skills. Passing it earns the Oracle Certified Associate, Java SE 8 Programmer credential. It validates foundational Java programming knowledge for the Java SE 8 certification path.
Exam Topics Java Basics 8–12% Working with Java Data Types 5–10% Using Operators and Decision Constructs 10–15% Creating and Using Arrays 5–10% Using Loop Constructs 5–10% Working with Methods and Encapsulation 8–12% Working with Inheritance 5–10% Handling Exceptions 5–10% Working with Selected Classes from the Java API 10–15% How to Use This Practice Exam Browse — Read each question, select your answer, and reveal the explanation.Exam Mode — Simulate real exam conditions with a timed session and score report.Learn Mode — Spaced repetition schedules questions you struggle with for long-term retention.Download the Full Exam PDF Get every question and answer in a clean, printable PDF built for offline study. Purchase once, keep permanent access, and re-download the latest version anytime.
Last updated July 12, 2026 at 9:42 PM
Topic filter All Topics Question sort Question Number
Question Q 1Java Basics Copy link Report a problem Ask AstroTutor Save question
Given:
How many MarkList instances are created in memory during runtime?
Show Answer Answer Explanation new MarkList() creates one object. Assigning obj1 to obj2 makes both variables refer to that same instance, while assigning null to obj3 creates no instance.
Question Q 2Working with Inheritance Copy link Report a problem Ask AstroTutor Save question
Question Q 3Using Operators and Decision Constructs Copy link Report a problem Ask AstroTutor Save question
Question Q 4Working with Inheritance Copy link Report a problem Ask AstroTutor Save question
Question Q 5Working with Methods and Encapsulation Copy link Report a problem Ask AstroTutor Save question It's free 100% of the questions are free for all users. No strings attached.
Topics covered Java Basics Working with Java Data Types Using Operators and Decision Constructs Creating and Using Arrays Using Loop Constructs Working with Methods and Encapsulation Working with Inheritance Handling Exceptions Working with Selected Classes from the Java API
Given these classes:
and this main method:
Which two options compile when placed at line n1 in the main method?
Choose two A director.stockOptions = 1_000; B employee.salary = 50_000; C manager.budget = 1_000_000; D manager.stockOption = 500; E employee.budget = 200_000; F director.salary = 80_000; Show Answer Answer Explanation Each variable has the declared type Employee, so compile-time member access permits its public salary field only. Although director refers to a Director object at runtime, fields such as budget and stockOptions are not accessible through an Employee-typed reference without a cast.
Which statement about the switch statement is true?
A Its expression can evaluate to a collection of values. B The break statement, at the end of each case block, is optional. C Its case label literals can be changed at runtime. D It must contain the default section. Show Answer Answer Explanation A break statement at the end of a case block is optional. If it is omitted and execution reaches the end of that block, control normally continues into the following case block (fall-through).
Given:
What is the output?
A C B A B C C A B C D Compilation fails at line n1 and line n2 Show Answer Answer Explanation Java inserts an implicit super() call as the first statement of each constructor when no explicit constructor invocation is written. Creating C therefore runs A's constructor, followed by B's constructor, and finally C's constructor, producing A B C.
Given this code fragment:
Which change allows the code to print 54321?
A Replace line 6 with System.out.print (--x); B At line 7, insert x --; C Replace line 5 with while (is Available(--x)) { D Replace line 12 with return (x > 0) ? false : true; Show Answer Answer Explanation Java passes an int argument by value, so decrementing x inside isAvailable changes only that method's parameter, not the x declared in main. Pre-decrementing x in the print statement changes the main variable from 6 through 1, producing 54321; the next condition call receives 1, evaluates its local copy to 0, and terminates the loop.
Question Q 6Working with Methods and Encapsulation Copy link Report a problem Ask AstroTutor Save question
Question Q 7Working with Methods and Encapsulation Copy link Report a problem Ask AstroTutor
Question Q 8Using Operators and Decision Constructs Copy link Report a problem Ask AstroTutor
Question Q 9Working with Inheritance Copy link Report a problem Ask AstroTutor
Question Q 10Java Basics Copy link Report a problem Ask AstroTutor
Question Q 11Working with Inheritance Copy link Report a problem Ask AstroTutor
Question Q 12Creating and Using Arrays Copy link Report a problem Ask AstroTutor
Question Q 13Working with Methods and Encapsulation Copy link Report a problem Ask AstroTutor
Question Q 14Using Loop Constructs Copy link Report a problem Ask AstroTutor
Question Q 15Working with Inheritance Copy link Report a problem Ask AstroTutor
Question Q 17Working with Selected Classes from the Java API Copy link Report a problem Ask AstroTutor
Question Q 18Working with Methods and Encapsulation Copy link Report a problem Ask AstroTutor
Question Q 19Using Operators and Decision Constructs Copy link Report a problem Ask AstroTutor
Question Q 20Working with Inheritance Copy link Report a problem Ask AstroTutor
Question Q 21Working with Selected Classes from the Java API Copy link Report a problem Ask AstroTutor
Question Q 22Working with Methods and Encapsulation Copy link Report a problem Ask AstroTutor
Question Q 25Using Operators and Decision Constructs Copy link Report a problem Ask AstroTutor
Question Q 26Using Loop Constructs Copy link Report a problem Ask AstroTutor
Question Q 27Working with Selected Classes from the Java API Copy link Report a problem Ask AstroTutor
Question Q 28Working with Selected Classes from the Java API Copy link Report a problem Ask AstroTutor Save question
Save question
Save question
Save question
Save question
Save question
Save question
Save question
Save question
Save question
Save question
Save question
Save question
Save question
Save question
Save question
Save question
Save question
Save question
Given:
What is the resulting output?
A 400 200 B 200 200 C 400 400 D Compilation fails. Show Answer Answer Explanation Java passes primitive values by value. The doCalc method doubles only its local copy of var1 and returns 400; the var1 declared in main remains 200.
Given:
And:
What is the resulting output?
A Option A B Option B C Option C D Option D Show Answer Answer Explanation A static field is shared by every instance, while each instance has its own ns field. The second constructor call does not satisfy s < ns, so that object's ns remains its default value of 0. The third constructor call updates the shared s to 125; therefore all three print calls show s = 125, while the instance values are 100, 0, and 125, respectively.
Given the following code fragment:
And the following 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.2.
Which two code fragments can independently be placed at line n1 to meet these requirements?
Choose two A Option A B Option B C Option C D Option D E Option E Show Answer Answer Explanation The conditions must preserve discount = 0.5 for every qty value of 90 or more, while assigning discount = 0.2 only for values greater than 80 and less than 90. Separate non-overlapping if statements or a conditional expression that tests qty >= 90 before qty > 80 satisfy those ranges.
Examine the following definitions:
and this code fragment:
Which statement is true regarding the implementation of Object-Oriented Programming concepts in the given code?
A Polymorphism, abstraction, and encapsulation are implemented. B Only polymorphism and inheritance are implemented. C Polymorphism, inheritance, and abstraction are implemented. D Only inheritance and encapsulation are implemented. Show Answer Answer Explanation The interface supplies an abstract contract, and Game provides its concrete operations. A Playable reference holding a Game object demonstrates polymorphism because the interface type can refer to an implementing object and invoke its implemented behavior. The private players field, accessed through methods, demonstrates encapsulation.
Learn more Which statement is correct about the main() method?
A It is invoked by JRE B It is a final method C It returns true if it is executed successfully at run time D It must be defined within a public class Show Answer Answer Explanation The Java runtime environment invokes an application's designated main method to start execution. A conventional Java entry-point method has a void return type and is not required to be final or enclosed in a public class.
Given:
And given this code fragment:
And this output:
Canine 60 Long -
Feline 80 Short -
Which two changes enable the code to print this output?
Choose two Show Answer Answer Explanation The one-argument constructor must initialize bounds while retaining Animal’s default type and maxSpeed, so it can call super() and assign this.bounds. The three-argument constructor must call super(type, maxSpeed) to initialize the inherited fields and then assign this.bounds. An explicit super(...) or this(...) constructor invocation must occur before ordinary constructor-body statements.
Learn more Consider:
MainTest.java:
and the commands:
What is the result?
A String main 1 B An exception is thrown at runtime C String main 1 2 3 D String main 123 Show Answer Answer Explanation Arguments following the class name are passed to main. Quotation marks group whitespace-containing text into one argument, so args[0] is 1 2 3; concatenating it with String main prints String main 1 2 3.
Learn more Given this class:
And this main method, located in a different class:
Which three lines, inserted independently at line n1, cause the program to print a balance of 0?
Choose three A acct.setAmount(-acct.getAmount()); B acct.amount = 0; C acct.setAmount(0); D acct.getAmount() = 0; E this.amount = 0; F acct.changeAmount(0); Show Answer Answer Explanation Negating the current balance with setAmount(-getAmount()) makes the balance zero because changeAmount(0) adds nothing. The public amount field can be assigned directly from another class, and the public setAmount method can set the balance to zero. These three alternatives guarantee that the printed balance is 0.
Given this code fragment:
And these requirements:
Process every array element in reverse order of entry.
Process every array element in order of entry.
Process alternating array elements in order of entry.
Which two statements are true?
Choose two A Requirements 1, 2, and 3 can be implemented by using the enhanced for loop. B Requirements 1, 2, and 3 can be implemented by using the standard for loop. C Requirements 2 and 3 CANNOT be implemented by using the standard for loop. D Requirement 2 can be implemented by using the enhanced for loop. E Requirement 3 CANNOT be implemented by using either the enhanced for loop or the standard for loop. Show Answer Answer Explanation A standard for loop can control the array index directly, allowing reverse traversal, normal forward traversal, and alternating-element traversal by changing the index start, condition, and increment. An enhanced for loop traverses an array sequentially in its entry order, so it can implement the forward-order requirement.
Examine the following definitions:
and this code fragment:
Which statement is true regarding the implementation of Object-Oriented Programming concepts in the code shown?
A Polymorphism, abstraction, and encapsulation are implemented. B Only polymorphism and inheritance are implemented. C Polymorphism, inheritance, and abstraction are implemented. D Only inheritance and encapsulation are implemented. Show Answer Answer Explanation Polymorphism is demonstrated because a Playable reference holds a Game object. Abstraction is provided by the Playable interface, which declares behavior independently of its implementation. Encapsulation is demonstrated by the private players field and its public accessor and mutator methods.
Which two statements about Java bytecode are true?
Choose two A It can be serialized across network. B It can run on any platform that has a Java compiler. C It can run on any platform. D It has ג€.javaג€ extension. E It can run on any platform that has the Java Runtime Environment. Show Answer Answer Explanation Java bytecode is platform-independent intermediate code that can be transmitted across a network. It runs on systems that provide a compatible Java Runtime Environment, which includes the Java Virtual Machine needed to execute the bytecode.
Given:
What is the output?
A 0:0 100:0 B null:0 100:0 C 0:0 100:200 D null:null 100:null Show Answer Answer Explanation Instance fields of primitive type int default to 0. Passing a Book reference allows the method to modify the referenced object's pages field, so it becomes 100. The int argument is passed by value, so assigning 200 to the parameter does not change count; it remains 0.
Given this code fragment:
What is the output?
A 3 B 4 C -1 D Compilation fails. Show Answer Answer Explanation A switch case continues into the following case unless it encounters break. Processing "mon" increments the value and falls through to the "wed" case, while "sun" and "sat" each decrement it. The final value printed is 3.
Consider the following classes:
Which two options fail to compile when inserted at line n1 in the main method?
Choose two A employee.salary = 50_000; B director.salary = 80_000; C employee.budget = 200_000; D manager.budget = 1_000_000; E manager.stockOption = 500; F director.stockOptions = 1_000; Show Answer Answer Explanation Field access is checked against the variable’s declared reference type. An Employee reference has no budget field, so employee.budget is invalid. A Manager reference has no field named stockOption; moreover, the declared Director field is named stockOptions (plural) and is not a member of Manager. Public fields inherited from a superclass remain accessible through subclass references.
Learn more Given:
What is the output?
A A B C D B A C D C A C D D D A B C C E A B D C Show Answer Answer Explanation Java String values are immutable. Each assigned concat call extends ta, but the unassigned replace("B", "C") result is discarded, so B remains unchanged. The printed value is A B C D.
Which statement most accurately describes encapsulation?
A Encapsulation ensures that classes can be designed so that only certain fields and methods of an object are accessible from other objects. B Encapsulation ensures that classes can be designed so that their methods are inheritable. C Encapsulation ensures that classes can be designed with some fields and methods declared as abstract. D Encapsulation ensures that classes can be designed so that if a method has an argument MyType x, any subclass of MyType can be passed to that method. Show Answer Answer Explanation Encapsulation lets a class control access to its data and behavior by making only selected fields and methods accessible to other objects.
Given this code fragment:
Which snippet on line 9 prints true?
A Boolean s = p.apply(101); System.out.println(s); B D System.out.println(p.apply(100)); Show Answer Answer Explanation A Predicate<Integer> is evaluated with test(Integer). The predicate returns true for 100 because 100 is even, so printing that result outputs true.
Given this code fragment:
What is the outcome?
A A B C Work done B A B C D Work done C A Work done D Compilation fails Show Answer Answer Explanation A Java break statement must occur within a loop or switch statement. Here, the loop has already ended before break is reached, so the code does not compile.
Given the following code fragment:
What is the output?
A [JavaForum, ExpertForum] B [JavaGroup, ExpertGroup] C [JavaForumGroup, ExpertForumGroup] D [JavaGroup, TechGroup ExpertGroup] Show Answer Answer Explanation String.concat returns a new string and does not alter the existing list element. The result produced during forEach is discarded, whereas List.replaceAll replaces every element with the result of its operator. The list therefore contains JavaGroup and ExpertGroup.
Learn more Given this code fragment:
What is the resulting output?
A A NullPointerException is thrown at runtime. B [1, 2, 4] C [1, 2, 4, null] D [1, 3, 4, null] E [1, 3, 4] F Compilation fails. Show Answer Answer Explanation For an ArrayList<Integer>, remove(1) invokes the overload that removes the element at index 1, so it removes 2. Calling remove(null) invokes the overload that removes the specified object, removing the null element. The list therefore contains [1, 3, 4].
Community Discussion