Interview Questions and Answers for 'Delphix' | Search Interview Question - javasearch.buggybread.com
Javasearch.buggybread.com

Search Interview Questions


 More than 3000 questions in repository.
 There are more than 900 unanswered questions.
Click here and help us by providing the answer.
 Have a video suggestion.
Click Correct / Improve and please let us know.
Label / Company      Label / Company / Text

   



Interview Questions and Answers for 'Delphix' - 2 question(s) found - Order By Rating

 Q1. How to write an iterator for an iterator of iterators?Core Java
Ans. CustomArrayList myarrayList = new CustomArrayList();
      myarrayList.add("Value 1");
      myarrayList.add("Value 2");
      myarrayList.add("Value 3");
      
      for (String string : myarrayList) {
         System.out.println(string);
      }



package sample.utils;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class CustomArrayList implements Iterable {

   private ArrayList mylist = new ArrayList();

   public void add(T t) {
      this.mylist.add(t);
   }

   @Override
   public Iterator iterator() {
      return new CustomIterator(mylist);
   }

   class CustomIterator implements Iterator {

      private int indexPosition = 0;
      private List internalList;

      public CustomIterator(List internalList) {
         this.internalList = internalList;
      }

      @Override
      public boolean hasNext() {
         if (internalList.size() >= indexPosition 1) {
            return true;
         }
         return false;
      }

      @Override
      public E next() {
         E val = internalList.get(indexPosition);
         indexPosition ;
         return val;
      }

   }

}

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     iterator     Asked in 1 Companies


Related Questions

  What is an Iterator?
  What are few iterator classes provided by Java ?
 What are fail-fast Iterators ?
 Is Iterator a class ?
 How Spliterator in Java 8 different than iterator ?
 Which is better in terms of performance - Iterator or Spliterator ?
 What are the cursors available in Java ?
 What is the difference between Enumeration and Iterator ?
 Why iterators of an array list are fail fast ?
 How can i split a linked list in two parts in java 8?


 Q2. How to find the median number in an array of integers ?Core Java
Ans.

Arrays.sort(numArray);
double median;
if (numArray.length % 2 == 0)
   median = ((double)numArray[numArray.length/2] (double)numArray[numArray.length/2 - 1])/2;
else
   median = (double) numArray[numArray.length-1/2];

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     coding     Asked in 2 Companies


Related Questions

  What are the steps to be performed while coding Junit with Mocking framework ?
  What is a Sequence File?
 What different level of logging you use while coding ?
 Have you ever encoded the response before sending it back from the service? If Yes , Which encoding was used ?
 What are the different type of encoding you have used ?
 How does encoding affect using Reader / writer classes or Stream classes in Java ?
 What is the difference between html encoding and url encoding ?
 Does spaces get's encoded in html encoding ?



Help us and Others Improve. Please let us know the questions asked in any of your previous interview.

Any input from you will be highly appreciated and It will unlock the application for 10 more requests.

Company Name:
Questions Asked: