Interview Experience with Amdocs for Java, React, and SQL

Author Profile Pic
Anurag
Published on Thu Jul 11 2024 ~ 6 min read
Interview Experience with Amdocs for Java, React, and SQL

I recently had the opportunity to interview with Amdocs for a Full Stack Developer position focusing on Java, React, and SQL. Here, I'll share my experience, the questions asked, and the solutions provided during the interview process.


Time Duration: 45 Min


Java Question


Question 1: Sort Array by Frequency

Implement a method to sort an array based on the frequency of elements.


import java.util.*;

public class FrequencySorter {
    public static int[] sortByFrequency(int[] array) {


        Map<Integer, Integer> frequencyMap = new HashMap<>();
        for (int num : array) {
            frequencyMap.put(num, frequencyMap.getOrDefault(num, 0) + 1);
        }

        List<Integer> list = new ArrayList<>();
        for (int num : array) {
            list.add(num);
        }

        list.sort((a, b) -> {
            int freqA = frequencyMap.get(a);
            int freqB = frequencyMap.get(b);
            if (freqA == freqB) {
                return Integer.compare(indexOf(array, a), indexOf(array, b));
            }
            return Integer.compare(freqB, freqA);
        });

        int[] sortedArray = new int[array.length];
        for (int i = 0; i < list.size(); i++) {
            sortedArray[i] = list.get(i);
        }

        return sortedArray;
    }

    private static int indexOf(int[] array, int value) {
        for (int i = 0; i < array.length; i++) {
            if (array[i] == value) {
                return i;
            }
        }
        return -1;
    }
}


Bitwise and Logical Operators


Question 2: Bitwise Operator

Predict the output of the expression true & true & false.

  • Explanation: The & operator performs a bitwise AND operation. It evaluates all operands regardless of the preceding values.
  • Steps:
  • true & true evaluates to true.
  • true & false evaluates to false.
  • Output: false.


Question 3: Logical And and OR Operator

Predict the output of the expression true && true && false.


  • Explanation: The && operator performs a logical AND operation and short-circuits, meaning if any operand is false, the entire expression evaluates to false immediately.
  • Steps:
  • true && true evaluates to true.
  • true && false (after the first part is true) evaluates to false.
  • Output: false.


Question 4: ArrayIndexOutOfBoundsException


How to throw an ArrayIndexOutOfBoundsException.

public class ArrayOutOfBoundExample {
    public static void main(String[] args) {
        int[] arr = {1, 2, 3};
        // Accessing an invalid index
        System.out.println(arr[3]); // This will throw ArrayIndexOutOfBoundsException
    }
}
  • Explanation: arr is an array of size 3, with valid indices 0, 1, and 2. Accessing arr[3] (an invalid index) will throw ArrayIndexOutOfBoundsException.


Question 5: Difference between ArrayList and LinkedList


  • ArrayList:
  • Implementation: Based on a dynamic array structure.
  • Access Time: Fast random access (O(1) time complexity).
  • Insertion/Deletion: Slower (O(n) time complexity).
  • Memory Overhead: Less memory overhead.
  • Usage: Preferred when frequent access to elements is required.
  • LinkedList:
  • Implementation: Based on a doubly linked list structure.
  • Access Time: Slower random access (O(n) time complexity).
  • Insertion/Deletion: Faster (O(1) time complexity).
  • Memory Overhead: More memory overhead.
  • Usage: Preferred when frequent insertions and deletions are required.


JavaScript & React Question


Question 6: Spread Operator

Predict the output of the following:


a = [123];
b = [...a];
a === b; // false
a == b; // false
  • Explanation: The spread operator ... creates a shallow copy of the array. Thus, a and b are different references.


Question 7: Logical Operators

Predict the output of the following:


0 || 24;  // 24
0 ?? 24;  // 0
  • Explanation: || returns the first truthy value, and ?? returns the first defined value.


Question 8: Implement 10 Page Input Form and Manage State

  • Solution: Use a state management library like Redux or Context API to manage the state of a multi-page form.


SQL


Question 9 Given a column in a table with the following values:


val
0
1
-1
-2
3
-2


Write a query to produce the following output:

Pos_val Neg_val
0 -1
1 -2
3 -2

You can write the query in the comment section...


Conclusion

My interview experience with Amdocs was engaging and challenging. The questions spanned various aspects of full-stack development, from SQL queries to Java programming and React concepts. Preparing for these topics thoroughly will undoubtedly help any candidate aiming for a similar role.

Comments


Loading...

Post a Comment

Address

Nirvana Apt, Hinjeadi, Pune, Maharastra - 411057 (India)

Website
Site : www.anucodes.in
Social