0% found this document useful (0 votes)
18 views1 page

JFSD Programing Test 13 JULY 2021 1

The document provides instructions for writing a Java program to replace duplicate elements in an input array with their corresponding index values. If the index is already present in the array, it should be incremented until a unique value is found. The program should take input from the console, pass it to a makePerfectArray method to get the modified output array, and print both the input and output arrays. The code should use two packages, test and perfect, with the main method and input/output arrays in the test package and the makePerfectArray method in the perfect package.

Uploaded by

Anu Vinod
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views1 page

JFSD Programing Test 13 JULY 2021 1

The document provides instructions for writing a Java program to replace duplicate elements in an input array with their corresponding index values. If the index is already present in the array, it should be incremented until a unique value is found. The program should take input from the console, pass it to a makePerfectArray method to get the modified output array, and print both the input and output arrays. The code should use two packages, test and perfect, with the main method and input/output arrays in the test package and the makePerfectArray method in the perfect package.

Uploaded by

Anu Vinod
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Java Full Stack Assessment Questions

Team A

Write a program in java to replace the duplicate elements in the given array with the
corresponding index value. if index values is already in that array elements, increase the index
until it becomes unique in that array elements .

5 7 8 5 4 7 6

For example scenario 1 : take 5

5 is duplicated at location 3 so replace 5 by its index 3 (but ensure that 3 is not available in
the array)

For example scenario 2 : take 7

7 is duplicated at location 5 so replaced it by the index 5, but 5 is already in the array so


increase index 5 by 1 that is 6 again check it in the array , 6 is available in the array so again
increase 6 by 1 so 7, again 7 is there so go for 8 , 8 is also there so that 9.

5 7 8 3 4 9 6

Note : -
1. Input should be taken from console in an array named “input” in the class
TestPerfect - main method
2. call and pass the input array to the makePerfectArray method, store the result
returned by the method in an array named “output” and should print input and
output array.
3. Create another class called PerfectArray with a static method named
makePerfectArray which accept an array as parameter and return the Perfect Array.
4. Use two different packages (package test and package perfect)

You might also like