CSE 205 Final Exam 2026: 100 Practice Questions
with Answers and Explanations | PDF
SECTION 1 (1–50) (Java Fundamentals, Variables, Loops, Conditions, Operators)
1. What will be the value of an integer variable after assigning 15 and then
adding 10 to it?
Answer: 25
Explanation: 15 + 10 = 25 using basic arithmetic addition.
2. What data type should you use in Java for storing true or false values?
Answer: boolean
Explanation: boolean stores only two values: true or false.
3. What will happen if you divide two integers like 7 divided by 2 in Java?
Answer: 3
Explanation: Integer division removes the decimal part.
4. What is the result of 10 % 3 in Java programming?
Answer: 1
Explanation: Modulus returns the remainder after division.
5. What keyword is used in Java to declare a constant variable?
Answer: final
Explanation: final prevents value changes after assignment.
,6. What will be printed if you concatenate "Hello" and 5 using + operator?
Answer: Hello5
Explanation: String concatenation converts numbers to text.
7. What is the default value of a boolean variable declared globally in Java?
Answer: false
Explanation: Instance variables default to false if not initialized.
8. What happens when you use == between two primitive integers in Java?
Answer: Value comparison
Explanation: == compares actual numeric values for primitives.
9. What will be the output of 5 + 2 * 3 in Java following operator precedence?
Answer: 11
Explanation: Multiplication happens before addition.
10. What symbol is used to write a single-line comment in Java code?
Answer: //
Explanation: Double slash comments out a single line.
11. What happens if a variable is declared but not initialized inside a method?
Answer: Compilation error
Explanation: Local variables must be initialized before use.
12. What is the result of comparing 10 > 5 in a Java program?
, Answer: true
Explanation: 10 is greater than 5, so condition is true.
13. What type of loop executes at least once regardless of condition?
Answer: do-while loop
Explanation: Condition is checked after execution.
14. What will be printed when using System.out.println(3 + "3")?
Answer: 33
Explanation: Number is converted to string and concatenated.
15. What is the result of logical AND (&&) when one condition is false?
Answer: false
Explanation: AND requires both conditions to be true.
16. What keyword is used to create an object in Java?
Answer: new
Explanation: new allocates memory for objects.
17. What will happen if you try to access an array index that does not exist?
Answer: Runtime error (ArrayIndexOutOfBoundsException)
Explanation: Java prevents invalid memory access.
18. What is the size of an int data type in Java?
Answer: 32 bits
Explanation: Java defines int as a 4-byte value.
with Answers and Explanations | PDF
SECTION 1 (1–50) (Java Fundamentals, Variables, Loops, Conditions, Operators)
1. What will be the value of an integer variable after assigning 15 and then
adding 10 to it?
Answer: 25
Explanation: 15 + 10 = 25 using basic arithmetic addition.
2. What data type should you use in Java for storing true or false values?
Answer: boolean
Explanation: boolean stores only two values: true or false.
3. What will happen if you divide two integers like 7 divided by 2 in Java?
Answer: 3
Explanation: Integer division removes the decimal part.
4. What is the result of 10 % 3 in Java programming?
Answer: 1
Explanation: Modulus returns the remainder after division.
5. What keyword is used in Java to declare a constant variable?
Answer: final
Explanation: final prevents value changes after assignment.
,6. What will be printed if you concatenate "Hello" and 5 using + operator?
Answer: Hello5
Explanation: String concatenation converts numbers to text.
7. What is the default value of a boolean variable declared globally in Java?
Answer: false
Explanation: Instance variables default to false if not initialized.
8. What happens when you use == between two primitive integers in Java?
Answer: Value comparison
Explanation: == compares actual numeric values for primitives.
9. What will be the output of 5 + 2 * 3 in Java following operator precedence?
Answer: 11
Explanation: Multiplication happens before addition.
10. What symbol is used to write a single-line comment in Java code?
Answer: //
Explanation: Double slash comments out a single line.
11. What happens if a variable is declared but not initialized inside a method?
Answer: Compilation error
Explanation: Local variables must be initialized before use.
12. What is the result of comparing 10 > 5 in a Java program?
, Answer: true
Explanation: 10 is greater than 5, so condition is true.
13. What type of loop executes at least once regardless of condition?
Answer: do-while loop
Explanation: Condition is checked after execution.
14. What will be printed when using System.out.println(3 + "3")?
Answer: 33
Explanation: Number is converted to string and concatenated.
15. What is the result of logical AND (&&) when one condition is false?
Answer: false
Explanation: AND requires both conditions to be true.
16. What keyword is used to create an object in Java?
Answer: new
Explanation: new allocates memory for objects.
17. What will happen if you try to access an array index that does not exist?
Answer: Runtime error (ArrayIndexOutOfBoundsException)
Explanation: Java prevents invalid memory access.
18. What is the size of an int data type in Java?
Answer: 32 bits
Explanation: Java defines int as a 4-byte value.