Google Interview Question for Software Engineer in Tests






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

delete [] array_name

- Java Coder October 10, 2008 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

where is the new?

- mal January 29, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

This seems to be a trick question.. They might be testing you to see how long does it take you to come to the conclusion that "You don't free memory using new, you use delete!"

- Boink boink October 11, 2008 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

In some OOP based languages like Java (or C#), an array is a reference type object.
So we can free memory allocated to it in the following way -
int[] arrI = new int[20];
// We need to free memory allocated to arrI
arrI = new int[0];

Hope this works for them!

- Rajat Kansal October 31, 2008 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

what's this.........

- shoushou January 16, 2009 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

@Rajat - that does not really *free* the mem.
All it does - mark them or tag them for deletion when garbage collector runs.
in .NET it has to be gc.Collect() - not recomended.

I do not think the question was asked properly.

- Lord Darth Plaguies June 26, 2009 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

it could be that the interviewer wants to know if you can free the memory 'from within another function' (guessing new function means that)
basically ownership of the memory created and how its managed.

- hgk August 21, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Deleting using new can be done via Placement new.
i.e.
you need to free a mem location: 0xCAFEBABE

Fred* f = new(0xCAFEBABE) Fred();

- Abhijith June 04, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

does not seem related to the question

cplusplusDOTcom/reference/std/new/operator%20new[]

- mal January 29, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

In Java may be this will work, correct me.

int[] arr = null; and then call System.gc();

- Badal November 04, 2012 | 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