Quiz Space

Java OPPE 1: September 2025 (September 2025 term)

Question 1

+25 marksProgramming

An organization maintains employee records with two attributes: currentExp (experience in the current company) and totalExp (overall work experience). Write a Java program that accepts currentExp and totalExp for 4 Employee objects, stores them in a TreeSet, and prints them in sorted order.

Employees are sorted by currentExp in ascending order. If the currentExp values are the same, they are sorted by totalExp in ascending order.

Requirements:

  • Define the compareTo method comparing currentExp first, then totalExp.
  • Return a negative number if this employee comes before the other, a positive number if it comes after, and 0 if they are equal.
  • A TreeSet automatically removes duplicates.

Input: 4 lines, each with two integers: the employee's experience in the current company and the total work experience. For each employee, totalExp >= currentExp.

Output: all Employee records stored in the TreeSet, in sorted order, one per line, in the format CurrentExp:<currentExp> TotalExp:<totalExp>.

More on the Java OPPE 1 Sept 2025 paper

The IIT Madras BS Programming Concepts using Java (Java) OPPE 1 paper sat on Sept 2025, in the September 2025 term: 1 question for 25 marks in 180 minutes. The first 1 question is below. Sign in with Google — it is free — to see the whole paper with its answers and explanations, in learning mode or as a timed mock test.

FeatureJava OPPE 1 Sept 2025 at a glance
TermSeptember 2025 term
SubjectProgramming Concepts using Java
Course codeBSCS2005
Questions1
Marks25
Duration180 min
Programming1
Official paperOPPE 1, Sep 2025
Negative markingNo negative marking.
Updated

Same OPPE 1, other subjects

More Java