2.9 of 5 24 reviews London, United Kingdom 500 to 999 Employees

CACI (UK) Software Technical Lead (Java) Interview Question

I interviewed in Saint Louis, MO and was asked:
"Write an AscendingSortedLongList and DescendingSortedLongList class ... and write some JUnit classes associated with them ..."
Tags: java
Add Tags [?]
Answer Flag Question

Part of a Software Technical Lead (Java) Interview Review - one of 9 CACI (UK) Interview Reviews

Answers & Comments

of 0
package sortedlist;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

 * Highly inefficient implementation of a sorted long list.
public class AscendingSortedLongList implements SortedLongList {
    protected ArrayList<Long> list;

    public AscendingSortedLongList() {
        this(new ArrayList<Long>());

    public AscendingSortedLongList(List<Long> initialList) {
        this.list = new ArrayList<Long>(initialList);

    protected void sort() {

    public void add(Long item) {

    public int getPositionOf(Long item) {
        return this.list.indexOf(item);

    public Long get(int position) {
        try {
            return this.list.get(position);
        } catch (IndexOutOfBoundsException e) {
            return null;

    public int length() {
        return this.list.size();

    public void printSortedContents() {
        boolean comma = false;
        for (Long longValue : this.list) {
            if (comma) {
                System.out.print("," + longValue);
            } else {
                comma = true;

    public SortedLongList reverseSort() {
        return new DescendingSortedLongList(this.list);
- Interview Candidate on Feb 20, 2012 Flag Response

To comment on this question, Sign In with Facebook or Sign Up

Tags are like keywords that help categorize interview questions that have something in common.

Glassdoor is your free inside look at CACI (UK) interview questions and advice. All interview reviews posted anonymously by CACI (UK) employees and interview candidates.