Questions with Answers and Explanations
Exam Overview
This comprehensive practice exam covers key topics in Object-Oriented
Programming and Data Structures typically assessed in CSE 205 courses. The
questions are organized into 8 thematic sections, mirroring the structure of a
standard university final examination .
SECTION 1: Java Fundamentals & Syntax (Questions 1-25)
Question 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 .
Question 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 .
Question 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 .
,Question 4:
What is the result of 10 % 3 in Java programming?
Answer: 1
Explanation: Modulus returns the remainder after division .
Question 5:
What keyword is used in Java to declare a constant variable?
Answer: final
Explanation: final prevents value changes after assignment .
Question 6:
What will be printed if you concatenate "Hello" and 5 using the + operator?
Answer: Hello5
Explanation: String concatenation converts numbers to text .
Question 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 .
Question 8:
What happens when you use == between two primitive integers in Java?
Answer: Value comparison
Explanation: == compares actual numeric values for primitives .
,Question 9:
What will be the output of 5 + 2 * 3 in Java following operator precedence?
Answer: 11
Explanation: Multiplication happens before addition .
Question 10:
What symbol is used to write a single-line comment in Java code?
Answer: //
Explanation: Double slash comments out a single line .
Question 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 .
Question 12:
What is the output of in integer division?
Answer: 4
Explanation: Decimal is discarded in integer division .
Question 13:
What does the increment operator ++ do to a variable?
Answer: Increases value by 1
Explanation: It adds one to the current value .
, Question 14: k0
What keyword is used to define a method that does not return anything?
k0 k0 k0 k0 k0 k0 k0 k0 k0 k0 k0 k0
Answer: void k0
Explanation: void means no return value .
k0 k0 k0 k0 k0 k0
Question 15: k0
What will be printed if x = 5 and x++ is executed then printed?
k0 k0 k0 k0 k0 k0 k0 k0 k0 k0 k0 k0 k0
Answer: 5 k0
Explanation: Post-increment uses original value first .
k0 k0 k0 k0 k0 k0
Question 16: k0
What is the output of System.out.println(10 == 10)?
k0 k0 k0 k0 k0 k0 k0
Answer: true k0
Explanation: Both values are equal . k0 k0 k0 k0 k0
Question 17: k0
What type of error occurs when syntax rules are broken in Java?
k0 k0 k0 k0 k0 k0 k0 k0 k0 k0 k0
Answer: Compile-time error
k0 k0
Explanation: Compiler detects incorrect syntax .
k0 k0 k0 k0 k0
Question 18: k0
What is stored in a char data type variable?
k0 k0 k0 k0 k0 k0 k0 k0
Answer: Single character
k0 k0
Explanation: Example: 'A', 'b', '#' . k0 k0 k0 k0 k0