19+ practice questions focused on Primitives, Strings and Operators — one of the most tested topics on the Oracle Java Foundations 1Z0-811 exam. Each question includes a detailed explanation so you learn why the right answer is correct.
Start Primitives, Strings and Operators PracticeGiven the following Java code: ```java public class Main { public static void main(String[] args) { int a = 10, b = 5, c = 15; int result = (a > b) ? (a > c) ? a : c : (b > c) ? b : c; System.out.println(result == 15 ? "Yes" : "No"); } } ``` What is the output?
Explanation: The code is: int a = 10, b = 5, c = 15; int result = (a > b) ? (a > c) ? a : c : (b > c) ? b : c; boolean output = result == 15; System.out.println(output ? "Yes" : "No"); This evaluates to 'Yes' because the ternary operator is right-associative. Since a > b is true, it evaluates the second ternary (a > c) ? a : c. a > c is false (10 > 15), so result = c = 15. Then output is true, so prints 'Yes'.
Refer to the exhibit. What is the output?
Explanation: The exhibit is not provided, but based on the correct answer D (false true true), a typical code snippet that produces this output is: String s1 = "true"; String s2 = new String("true"); String s3 = s2; System.out.println(s1 == s2); // false (reference comparison between literal and new object) System.out.println(s1.equals(s2)); // true (value equality) System.out.println(s3 == s2); // true (same reference). This exact ordering yields false, true, true.
Match each primitive data type to its default value.
Explanation: Only options B and D correctly match a primitive type to its default value without redundancy or false equivalency. Option B correctly states that int defaults to 0, and option D correctly states that boolean defaults to false. Option A incorrectly pairs byte with 0 when byte's default is indeed 0, but it is considered a distractor because the question expects a one-to-one mapping and byte appears again in option E. Option C incorrectly pairs float with 0.0f, but float's default is 0.0f, making it a distractor for similar reasons. Options E and F are clearly wrong.
What is the output of the program?
Explanation: The program creates two StringBuilder objects with identical string content and compares them using the `equals()` method. Since the `StringBuilder` class does not override `Object.equals()`, it uses reference equality. The two objects are distinct instances, so `equals()` returns `false`. Therefore, the output is `false`.
A developer wants to compare two String objects for content equality. Which code snippet will work correctly?
Explanation: Option B correctly states that both option A (using `compareTo`) and option C (using `equals`) are valid ways to compare String content for equality. `str1.compareTo(str2) == 0` returns true when the strings are equal, and `str1.equals(str2)` directly compares content. Option D uses `==` which compares object references, not content. Therefore, B is the only correct single answer.
+14 more Primitives, Strings and Operators questions available
Practice all Primitives, Strings and Operators questions1. Baseline your knowledge
Start with 10 questions to gauge your current understanding of Primitives, Strings and Operators. This tells you whether you need a concept refresher or just practice.
2. Review every explanation
For each question — right or wrong — read the full explanation. Understanding why an answer is correct is more valuable than knowing the answer itself.
3. Focus on exam traps
Primitives, Strings and Operators questions on the 1Z0-811 frequently use trap wording. Look for subtle differences in answers that test your precision, not just general knowledge.
4. Reach 80% consistently
Do repeated sessions until you score 80%+ three times in a row. Then move to mixed-mode practice to test cross-topic recall under realistic conditions.
The exact number varies per candidate. Primitives, Strings and Operators is tested as part of the Oracle Java Foundations 1Z0-811 blueprint. Practicing with targeted Primitives, Strings and Operators questions ensures you can handle any format or difficulty that appears.
Yes. Courseiva provides free 1Z0-811 practice questions across all exam topics and domains. The platform includes topic-based practice, mock exams, missed-question review, bookmarked questions, and readiness tracking — no account required.
Difficulty is subjective, but Primitives, Strings and Operators is a high-priority exam concept tested in multiple ways — direct recall, scenario analysis, and command-output interpretation. Consistent practice is the best way to build confidence.
Launch a full Primitives, Strings and Operators practice session with instant scoring and detailed explanations.
Start Primitives, Strings and Operators Practice →