Walmart Labs Interview Question for Applications Developers


Country: India
Interview Type: In-Person




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

Couple of things, from .Net perspective
1. if you make any changes to the above new assemblies version is created and we can have multiple version assemblies.
2. When you have new version of and what to reference it you will have to recompile the code.

- Jai December 04, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

If this were C++, the issue would be which of the changes affect the layout of the object. Code which uses the affected class will likely make inappropriate accesses when they access fields as they assume the old layout. Bugs from this will likely be very hard to diagnose.

Adding a data member typically changes the object layout though in some app compat cases people add a field and shrink another. This is not 100% safe, it depends on how the fields are accessed, so best to avoid.

If the class had no other virtual methods before adding a virtual destructor, then the addition a virtual method will change object layout to include a vtable pointer. It's an implementation detail, but this is typically at the start of the object so all fields shift by the vtable pointer size.

Adding new methods does not and the existing libraries can't call them.

Probably worth pontificating that you absolutely never want to ship out of date libraries, better to build everything against a known point.

- MrZipf December 04, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

d. adding a argument with default value would need a recompilation for sure...
c. make destructor virtual -- I don't remember any such concept in java..
java -- has finalize methord to do last time clean up and GC

- shreyans December 07, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

This is obviously a C++ question (mentions virtual destructor).
C++ ABI isn't standardized and answers depend on bunch of implementation details, but for most of the compilers all the changes a,b,c,d are generally unsafe.

For each case (a,b,c,d) there are numerous "safe" special cases.
For instance changing a signature of non-virtual method which was never called is safe, or introducing a data-field to a class whose layout is never observed by the client code (directly or indirectly via inlined functions), so on.

- 0xF4 December 14, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

For Java, adding a constructor can mess up things.
In case where there is no constructor defined in class, if you define a parameterized constructor, then all the instantiations of this class using default constructor will fail.

- vikrantgoel7 May 30, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 1 vote

c. change destructor into virtual

- Arif December 04, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

incorrect. This is generally unsafe.

It could be safe only in some edge cases.. E.g. on most compilers it will be safe IF: class already had a virtual method AND the destructor is never called on a base class pointer from the client code (directly or indirectly via all forms of inlining).

- 0xF4 December 14, 2014 | Flag


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