Java Fundamentals
Final Assessment (Qns & Ans)
2025
General Instructions
1. Read All Questions Carefully: Make sure you understand each question.
2. Time Management: You have a specific amount of time to complete the exam.
Keep an eye on the clock and pace yourself.
3. Allowed Materials: Only use materials that are explicitly allowed. Unauthorized
materials can lead to disqualification.
4. ANS Format: Follow the required format for your ANS. For example, multiple-choice
questions might need you to select the best ANS, while essay questions require
detailed responses.
5. Academic Integrity: Adhere to the university's honor code. Any form of cheating or
plagiarism is strictly prohibited.
6. Technical Requirements: Ensure your computer and internet connection are
stable. For online exams, you might need a webcam and microphone for proctoring
purposes.
7. Submission: Submit your ANS before the time expires. Late submissions might not
be accepted.
©2024/2025
,1. Which of the following methods in Java overrides the
`equals()` method?
A) `public boolean equals(Object obj)`
B) `public int compareTo(Object obj)`
C) `public int hashCode()`
D) `public boolean isEqual(Object obj)`
Correct ANS: A
Rationale: The `equals()` method is defined in the Object
class, and overriding it requires a method signature of `public
boolean equals(Object obj)`.
2. What keyword in Java is used to define a constant value that
cannot be changed?
A) static
B) final
C) const
D) immutable
Correct ANS: B
©2024/2025
, Rationale: The `final` keyword is used to declare constants in
Java, preventing them from being modified after initialization.
3. Which collection class allows duplicate elements?
A) HashSet
B) TreeSet
C) ArrayList
D) LinkedHashSet
Correct ANS: C
Rationale: ArrayList allows duplicate elements, while
HashSet and TreeSet do not permit duplicates.
4. Which of the following can be used to synchronize access to a
block of code?
A) synchronized methods
B) synchronized block
C) Both A and B
D) None of the above
Correct ANS: C
©2024/2025
, Rationale: Both synchronized methods and synchronized
blocks can be used to manage synchronization in Java.
5. What is the result of calling `Integer.valueOf(128)`?
A) New Integer object
B) Cached Integer object
C) Null
D) Integer.MAX_VALUE
Correct ANS: A
Rationale: Values from -128 to 127 are cached in Integer
class, but outside this range, a new object is created.
Fill-in-the-Blank Questions
6. In Java, __________ is a mechanism by which one object is
allowed to use the properties and methods of another object.
Correct ANS: inheritance
Rationale: Inheritance allows one class to inherit fields and
methods from another class.
©2024/2025