Instructions & Guidelines to Candidates
View README.mdExam Rules
- Follow the class diagram strictly. Read the problem statement, examples and the other details provided carefully and implement the solution.
- Code submitted with compilation errors may not get evaluated.
- DO NOT add any new method apart from the one given in the file where you write the solution.
- DO NOT alter the method name or the argument list of the method that is provided to you.
- DO NOT write codes that result in infinite loops / infinite recursive calls, because it just won't work!
- The test cases provided are a subset of test cases that will be used to test your code.
- Removal / modification of package statements
- Infinite loops / infinite recursive calls
- Class diagram violation
- Improper constructor prototype or definition
Question 1: Programming Fundamentals — Token Validation
Problem Description
Mr. Charles is developing a pharmaceuticals system to generate a verification token based on the input string. Write code in the given Java method to implement the requirement.
Input & Output Format
- Input: A
Stringcontaining at most one$character. - Output: Returns a
String. - Constraints:
input string length >= 1
Validation Rules
- Check whether the input string contains two parts separated by a
$in the format<part1>$<part2>. - If format is valid (both parts non-empty):
part1must contain only lowercase alphabets (a-z).part2must contain only digits (0-9).
- Return:
- If both conditions satisfied: return
"<part1>_valid" - Otherwise: return
"<part1>_invalid"
- If both conditions satisfied: return
- If the input string does not follow the required format (e.g. missing
$, multiple$, empty parts): return"invalid".
Sample Test Cases
| Example | Input | Expected Output | Explanation |
|---|---|---|---|
| 1 | "colpol$01" |
"colpol_valid" |
Valid format, part1 is lowercase letters, part2 is digits |
| 2 | "123e$456" |
"123e_invalid" |
Valid format, but part1 contains digits |
| 3 | "dolo650" |
"invalid" |
Missing '$' delimiter |
| 4 | "crocin$50$" |
"invalid" |
Contains multiple '$' symbols |
Question 2: Programming Fundamentals — Inventory Batch Audit
Problem Description
The "CERT-AO" organization audits inventory batches. Write code in the given Java method to implement the requirement.
Input & Output Format
- Input:
- 1D integer array named
actualArrrepresenting actual quantities. - 1D integer array named
thresholdArrrepresenting target threshold values.
- 1D integer array named
- Output: Returns a 1D String array named
outArr. - Constraints:
0 <= actual quantity <= 99,0 <= target threshold <= 99, arrays have identical length.
Rules
- For each element at index
iinactualArr:- If
actualArr[i] >= thresholdArr[i]: add"<element>_RELEASED"tooutArr. - Otherwise: add
"<element>_REJECTED"tooutArr.
- If
- Process for all elements and return
outArr.
Sample Test Cases
| # | actualArr | thresholdArr | Expected Output (outArr) |
|---|---|---|---|
| 1 | [8, 3, 24, 28, 55, 44] |
[5, 5, 6, 25, 18, 42] |
["8_RELEASED", "3_REJECTED", "24_RELEASED", "28_RELEASED", "55_RELEASED", "44_RELEASED"] |
| 2 | [6, 77, 66, 23] |
[5, 99, 50, 68] |
["6_RELEASED", "77_REJECTED", "66_RELEASED", "23_REJECTED"] |
| 3 | [10, 15, 20, 21, 10] |
[20, 25, 31, 23, 15] |
["10_REJECTED", "15_REJECTED", "20_REJECTED", "21_REJECTED", "10_REJECTED"] |
| 4 | [29, 10, 31, 55, 35] |
[20, 5, 20, 20, 10] |
["29_RELEASED", "10_RELEASED", "31_RELEASED", "55_RELEASED", "35_RELEASED"] |
Question 3: Object Oriented Programming — UpSkill Certification
"UpSkill" global educational organization offers training and certification. To get certified, users must take a prerequisite course and pay fees for both. Automate fee calculation based on the given class diagram.
Rebuilt High-Resolution UML Class Diagram
Class & Method Specifications
| Class | Method Name & Signature | Implementation Details |
|---|---|---|
| Course | identifyCourseFee(): int |
Code provided, no need to implement |
| Certification | generateCertificationId(): void |
Code provided, no need to implement |
identifyModeOfCertificationFee(): int |
Code provided, no need to implement | |
| Employee (extends Certification) |
validateEmployee(): boolean |
Code provided, no need to implement |
identifyDiscountPercent(certification: Certification): Integer |
Code provided, enhance as per requirement | |
calculateTotalFee(certification: Certification): void |
Need to be implemented |
Logic Requirements
1. identifyDiscountPercent(certification: Certification): Integer
The current implementation sets discount of 10 if employee is valid (validateEmployee() == true), else 0.
Enhance the logic to update discount percent:
- If the mode fee identified by
certification.identifyModeOfCertificationFee() >= 350, provide an additional discount of 5. - Identify additional discount based on course fee determined by
course.identifyCourseFee():Course Fee Additional Discount 4500 and above 10 Between 3500 (inclusive) and 4500 (exclusive) 8 Between 2500 (inclusive) and 3500 (exclusive) 5 - Return final discount percent (e.g. 10 + 5 + 5 = 20%).
2. calculateTotalFee(certification: Certification): void
- Invoke
course.identifyCourseFee()to identifycourseFee(double). - Identify
basicFee(int) as 5000. - Invoke
validateEmployee()method. - If
validateEmployee() == trueANDcourseFee != -1.0:- For
reqCourseTypepresent in first row ofcourseTypeArr({"Concept Based", "Hands-On", "Hybrid"}), identifycost(double) from second row ({"200.0", "500.0", "1000.0"}). Perform case-sensitive comparison. - Update cost:
cost = cost + basicFee + courseFee. - If
employeeTypeis"Trainee"ANDorgNameis"Infosys"(perform case-insensitive comparison): deduct 2000.0 from cost. - Set
certificationFeeof Certification class with the identified cost. - Invoke
certification.generateCertificationId().
- For
- Otherwise:
- Set
certificationFeeto -1.0. - Set
certificationIdto "NA".
- Set
Question 4: Data Structures — Queue Coupon Classification
Problem Description
An e-commerce system stores coupons in the order they arrive. It also prevents misuse of blocked coupons. Write code in the given Java method to classify coupons based on the rules.
Input & Output Format
- Input:
ArrayDeque<Integer> allowedQueue(coupons in sequence)ArrayList<Integer> blockedList(blocked coupons)
- Output: Returns
ArrayDeque<String> outQueue. - Constraints:
0 <= number of coupons <= 10,1000 <= coupon value <= 9999.
Classification Rules
For each coupon processed from front to rear:
- If the coupon:
- Appears more than once in
allowedQueue, AND - Is not present in
blockedList
"<coupon>_EC"in a temporary data structure. - Appears more than once in
- Otherwise:
→ Classify as "IC" (Invalid Coupon) and add
"<coupon>_IC"directly to the output queue. - After processing all elements: → Append all elements from the temporary data structure in reverse order to the output queue.
Sample Test Cases
| allowedQueue (Front→Rear) | blockedList | tempDataStructure | outQueue (Front→Rear) |
|---|---|---|---|
[4820, 1999, 4820, 2501, 2501, 6000, 3200, 3200] |
[2501, 7000] |
{"4820_EC", "4820_EC", "3200_EC", "3200_EC"} |
["1999_IC", "2501_IC", "2501_IC", "6000_IC", "3200_EC", "3200_EC", "4820_EC", "4820_EC"] |
[3000, 3000, 4200, 4200] |
[3000, 4200] |
- |
["3000_IC", "3000_IC", "4200_IC", "4200_IC"] |