Third interview - programming test

Pages: 123
I applied to a jr. software developer position 2 weeks ago. I had a phone interview, an in person interview, and now they want me back for a programming test. What types of things can I expect to see on this test for a "learning position" jr. software development position. I'm solid on programming logic (loops arrays etc..). As for specific language knowledge I think they use Javascript, C++, and SQL Server but I already told them I have no experience with Javascript.

I hope it's just logic. I have made a few functional relational databases and worked with SQL Query language a bit in my PHP days (last month hehe). Anybody have any suggestions on what I should be focusing on or what will be on the "programming test"?
Last edited on
I just had an interview for a similar position. I interviewed with two different engineers who worked in two different vastly different areas. Anyways, I was asked things like:

Implement a binary search for a given set of sorted numbers
Show how a binary search tree would be represented for a string of letters
How would you design a chess game using OOP principles
What is the benefits of having classes in a given situation
Debug a method (mine dealt with string replacement)
Write a unit test
Find null pointer exceptions
Explain the difference between managed and unmanaged languages
Some database questions (I told them I knew nothing about them so they just moved on)
Insert a node into a linked list
It's going to be a long week..
None of this was really difficult. We can help you if you have any questions
Yeah. I'm having trouble understanding heap based vs stack based objects for classes. For example, why would you want to use heap vs stack for an object?

1
2
3
Calculator myCalc; // stack-based Calculator

Calculator* myCalc2; // heap-based Calculator 


Also pointers. I know pass by references, but pointers are a bit shady as well as the arrow operator (->) never used it, which I think is connected in some way with my first question and heap (memory based) objects.
Last edited on
Stack is for temporary stuff... goes out of scope, gets cleaned up/deleted automatically.

Heap is for your own management. (new/delete)
Well, what you just showed are both variables on the stack. The first creates an object of type Calculator, while the second is just a pointer of type Calculator.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Calculator myCalc; //Stack object
Calculator *ptrCalc; //Stack pointer
ptrCalc = new Calculator; //ptrCalc now points to an object on the heap, but ptrCalc still resides on the stack.

delete ptrCalc; //Frees the memory pointed to by ptrCalc. ptrCalc is still alive and well though

ptrCalc = new Calculator; //Same as above, you can reuse a pointer.
ptrCalc->someMethod(); //-> is equivalent to (*ptrCalc).someMethod()

delete ptrCalc;

EDIT:
//Can also do
Calculator* pointer;
Calculator calc;
pointer = &calc; //Everything here is on the stack 
Last edited on
Oria, great info. Makes sense. ResidentBiscuit, line 8. equivalent to (*ptrCalc) - what does this mean? Does it mean .someMethod() is a method of whatever class ptrCalc is assigned?

Also if I create an object on the heap, as in line 3, is that meant for dynamic memory management?
Last edited on
Since ptrCalc is just a pointer, you have to dereference it in order to work with what it points to.

1
2
(*ptrCalc) //This dereferences the pointer, returns what it points to.
.someMethod() //Now that we have the object, we can call a method from it 


-> is just shorthand for the above.
Last edited on
Not too difficult to understand thanks. I solidify memory of what I learn by practicing, so I will try to use pointers and classes in my preparations. Thanks!
Also you will generally want to use the heap for large objects or arrays. The stack space your program gets from the OS is allocated at startup and cannot become any larger (you generally get a few MB's I think). If you try to use more stack memory than you have available you get an error called a stack overflow. The heap doesn't have such size limitations though, you can keep allocating more memory until you exhaust all of the available physical memory on the computer.
until you exhaust all of the available physical memory on the computer


int crash[1000000][1000000];
Last edited on
And how many GB of memory did you just set there Oria? Like 6GB? lol That seems to be like 1 trillion bytes

EDIT* each int is 4 bytes so multiple that figure by 4 = 4 trillion bytes.

Nope that's 29 Terabits of memory, I think.

Wow 4 trillion bytes is only 0.003552713678800501 Petabytes, but 29 Terabits:

https://www.google.com/search?q=bytes+to+gb&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a

Firefox Rules
Last edited on
Actually, 14901.2 GB.

(1000000 x 4 byte) x (1000000 x 4 byte) = 16000000000000 bytes.
omg! Ya that'll do the trick
I wanted to overkill :p
Last edited on
(1000000 x 4 byte) x (1000000 x 4 byte) = 16000000000000 bytes.


?
I think you mean (1000000 x 1000000) x 4 bytes = 4*10^12
Right I guess so. Will still crash mostly anything though.
Ok so what would be the benefit of creating a reference to an object using these two methods? I'm still unclear, I thought C++ automatically created a object when you assign a class variable.

1
2
3
4
className classVariable;
// vs //
className classVariable;
classVariable = new className;

@rcast


The first statement creates an object of type className in C++. The third statement give you an error in C++.

However in C# the first statement create a reference to an object of type className that will be equal to null. The third statement creates an object in the managed heap in C# and assigns its reference to classVariable.
Pages: 123