Interview Question for Developer Program Engineers


Team: Yandex
Country: Russia
Interview Type: Written Test




Comment hidden because of low score. Click to expand.
1
of 1 vote

As i understood from question....
1. Make ArrayList as generic type.
2. Change default capacity to user defined capacity.
3. Default capacity is 10 you can change and make it 1.
i.e. ArrayList<E> list = new ArrayList<E>(1).

Please make comment if i misunderstood the problem.

- Sharma October 03, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

There are two optimizations depending on the scenario. If you know the specific type of data the container would hold, you should identify that generic using the <> syntax. Secondly, if you know this list will be holding some large amount of data (more than the default 10 that are declared) you could go ahead and allocated that with the constructor and provide an initial size to more closely reflect your array's needs. This will prevent unnecessary resizing and recopying as the arraylist is loaded.

- masterjaso October 03, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 1 vote

new returns the address of the object hence we need to assign to the pointer.

Code need astricks (*) infront of list vairable. i.e. ArrayList *list = new ArrayList();

- hprem991 October 03, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 1 vote

List<T> someList = new ArrayList<T>();

- CupCoffee October 03, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 1 vote

List<T> list = new ArrayList<T>();

- Deepak October 03, 2013 | Flag Reply


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More