Java Objective Assessment Study Guide
(2026/2027) | WGU Exam Review
Question 1: Java Primitive Arithmetic
What is the value stored in the variable result after executing the following Java code snippet?
Java
int a = 19;
int b = 4;
int result = a / b + a % b;
• A. 7.75
• B. 7
• C. 8
• D. 4
Correct Answer: B. 7
Rationale:
1. Integer division a / b () truncates the decimal portion, resulting in 4.
2. Modulus a % b (19 % 4) evaluates to the remainder, which is 3.
3. Summing the results: 4 + 3 = 7.
Question 2: Loop Control Flow
How many times will the string "WGU Java" be printed to the console when executing the
following loop?
Java
int count = 0;
do {
System.out.println("WGU Java");
count += 2;
} while (count < 5);
• A. 2 times
• B. 3 times
• C. 5 times
, • D. 0 times
Correct Answer: B. 3 times
Rationale: Tracing execution in a post-test do-while loop:
• Pass 1: Prints "WGU Java", count becomes 2. Condition 2 < 5 is True.
• Pass 2: Prints "WGU Java", count becomes 4. Condition 4 < 5 is True.
• Pass 3: Prints "WGU Java", count becomes 6. Condition 6 < 5 is False (loop
terminates).
Total printed = 3 times.
Question 3: Array Indexing & Bounds
Given the array declaration double[] values = new double[6];, which expression references
the final element in the array?
• A. values[6]
• B. values[5]
• C. values.length
• D. values[values.length]
Correct Answer: B. values[5]
Rationale: Java arrays are zero-indexed. An array allocated with size 6 has valid index positions
0, 1, 2, 3, 4, 5. Referencing values[6] causes an ArrayIndexOutOfBoundsException.
Question 4: Object-Oriented Principles
Which Java programming keyword is used inside a class constructor or instance method to
resolve ambiguity when a local parameter name is identical to an instance variable field name?
• A. super
• B. this
• C. static
• D. void
Correct Answer: B. this
Rationale: The this reference variable points directly to the current object instance, explicitly
differentiating instance variables (this.name) from shadowing parameter variables (String
name).
Question 5: Method Overloading Rules
,Which modification to a method signature establishes valid Method Overloading in a Java
class?
• A. Changing only the method return type from int to double.
• B. Changing the parameter list by altering the parameter data types or quantity.
• C. Changing only the access modifier from private to public.
• D. Changing the parameter variable names while keeping parameter types identical.
Correct Answer: B. Changing the parameter list by altering the parameter data types or
quantity.
Rationale: Method overloading requires changing the parameter signature (number, order, or
data types of parameters). Simply altering the return type or access modifier without changing
parameters causes a compilation syntax error.
Would you like to generate additional practice question sets covering specific topics like String
manipulation (StringBuilder, .equals()), inheritance/polymorphism, or basic exception
handling (try-catch) next?
Question 6
Which primitive data type in Java is specifically designed to store a 64-bit double-
precision floating-point number?
• A. float
• B. double
• C. long
• D. int
Correct Answer: B. double
Rationale: double is a 64-bit floating-point type, whereas float is 32-bit. double is the
default choice in Java for decimal numbers.
Question 7
What is the result of evaluating the integer division expression in Java?
• A. 3.75
• B. 3
• C. 4
• D. 3.0
Correct Answer: B. 3
, Rationale: When both operands are integers, Java performs integer division, truncating
the fractional remainder.
Question 8
Which operator is used to calculate the remainder of division between two integer
values?
• A. /
• B. *
• C. %
• D. ^
Correct Answer: C. %
Rationale: The modulo operator (%) returns the integer remainder of division.
Question 9
What is implicit type casting (widening conversion) in Java?
• A. Automatically converting a smaller primitive type to a larger compatible type
(e.g., int to double).
• B. Manually casting a double to an int using parentheses (int).
• C. Converting strings into booleans.
• D. Compiling code into bytecode.
Correct Answer: A. Automatically converting a smaller primitive type to a larger
compatible type (e.g., int to double).
Rationale: Widening conversions happen automatically without data loss risk, handled
seamlessly by the Java compiler.
Question 10
Which of the following is an illegal variable identifier name in Java?
• A. userScore
• B. _totalCount
• C. 2ndAttempt
• D. $taxRate
Correct Answer: C. 2ndAttempt
Rationale: Variable identifiers in Java cannot begin with a numeric digit.