Você está na página 1de 6

Nisarg Dave

Saks Direct Application Developer Evaluation


Name:
Date:
The following questions are not designed to trick you; they simply represent the kind of problems that you
will encounter on a regular basis as a software developer. Please read the questions carefully, though.
Some will take only a few seconds, some may take a few minutes. Some questions ask you to write code;
theres no one right answer to these, we just want to see how you would do it if you were really asked to do
it at work. We have provided you with some scrap paper as well; if you choose to use it for some of your
answers, please clearly indicate that you have done so.
Please print your name at the top of each page. Relax, and enjoy yourself!
1. Heres some code written in a hypothetical object-oriented programming language, one that looks a lot
like Java, C#, Ruby, etc
Class Foo
public void setX(int x) {
my.x = x;
}
public int getX() {
return my.x;
}
}
If we then write this:
Foo a = new Foo();
Foo b = a;
a.setX(5);
b.setX(10);
What is the value of a.getX()?
What is the value of b.getX()?

Nisarg Dave

2. In a language of your choice, write a code snippet that prints the integers from 1 to 100. If an integer is
a multiple of 3, print Foo instead of the integer. If an integer is a multiple of 5, print Bar instead of the
integer. If the integer is a multiple of 3 and 5, print FooBar instead of the integer.
Coded in C++
For the sake of OOP, wrote more code
Assumed when integer is a multiple of 3 and 5, we are checking for both and not 15. Hence put
the or condition.
#include <iostream>
#include <string>
using namespace std;
class displayNosWithStringReplacements{
public:
void displayWithNoStringReplacement(int n);
void displaywith1StringReplacement(int n, std::string str);
void displaywith2StringReplacements(int n, int m, std::string str);
};
void displayNosWithStringReplacements::displayWithNoStringReplacement(int n){
for (int i = 1; i <= 100; ++i){
cout << i << " ";
}
cout << "\n";
}
void displayNosWithStringReplacements::displaywith1StringReplacement(int n, std::string str){
for (int i = 1; i <= 100; ++i){
if ((i % n) == 0){
cout << str << " ";
}
else{
cout << i << " ";
}
}
cout << "\n";
}
void displayNosWithStringReplacements::displaywith2StringReplacements(int n, int m, std::string str){
for (int i = 1; i <= 100; ++i){
if (((i % n) == 0) || ((i % m) == 0)){
cout << str << " ";
}
else{
cout << i << " ";
}
}
cout << "\n";
}
int main(){
const std::string str = "", str1 = "Foo", str2 = "Bar", str3 = str1 + str2;;
displayNosWithStringReplacements a;

ii

Nisarg Dave

a.displayWithNoStringReplacement(1);
cout << endl;
a.displaywith1StringReplacement(3, str1);
cout << endl;
a.displaywith1StringReplacement(5, str2);
cout << endl;
a.displaywith2StringReplacements(3, 5, str3);
cout << endl;
return 0;
}
3. In hexadecimal, what is the number after F?
10 where 1 is the new digit place and 0 for the completed bit which restarts.
4.

Write a method in either Java or C# that will find the largest value in an array of integers.

using System;
namespace ConsoleApplication8
{
class Program
{
static void Main(string[] args)
{
int[] arr = new int[10];
Random randomNumber = new Random();
Console.WriteLine("The array contain:");
for(int i = 0; i < 10; i++){
arr[i] = randomNumber.Next(1, 100);
Console.WriteLine("{0}", arr[i]);
}
Max(arr);
Console.Read();
Console.Read();
}
static void Max(int [] arr){
int maxNumber = 0;
for (int i = 0; i < arr.Length; i++)
{
if ( arr[maxNumber] < arr[i] )
{
maxNumber = i;
}
}
Console.WriteLine("The maximum number is: {0}", arr[maxNumber]);

iii

Nisarg Dave
}
}
}

5. We have a website that contains 50,000 web pages. Some of those pages contain phone numbers,
which are all either in the form (xxx) xxx-xxxx or xxx xxx-xxxx. All the files are stored on a single
filesystem on a Unix-like machine to which you have access. You have been given the task of producing a
list of all the pages that contain phone numbers. Describe what youd do.

grep nr (xxx) xxx-xxxx* .


-n for line number
-r for recursive searching through files
* finds all matching patterns
. current directory
And for xxx xxx-xxxx
grep nr xxx xxx-xxxx*.
6. In the language of your choice, write some code that prints the sum of the values in an array of
integers, without using a loop. For example, given an array containing (1,2,4), your function would return
Using C++ and recursion
#include <iostream>
#include <stdlib.h>
int SumofArray(int arr[], int n){
int sum = 0;
if(n < 0){
return sum;
}
else{
return arr[n] + SumofArray(arr, n - 1);
}
}
int main(){
int arr[] = { 1, 5, 3, 6, 8, 4, 2, 9, 7, 10 };
std::cout << "The sum of elements of the array is: " << SumofArray(arr, 9) << std::endl;
return 0;
}
7.

Why is this joke funny?


Q: Why do software developers get Halloween and Christmas confused?
A: Because DEC 25 is OCT 31

iv

Nisarg Dave
Dec 25 can be coined as decimal 25 = 11001 in binary
Oct 31 can be coined as Octal 31 = 11001 in binary
Thus, Equal.
8. What is the difference between these two operators: & and &&?
& is bitwire AND and && is logical AND (short-circuit AND)
9. You are a consultant who has been hired to write some software for a company that runs parking
garages. After a brief initial discussion with the client, all you know is that they want a system that will
provide insight into the state of all their garages in real time -- how many vehicles are currently in the
garages, the breakdown of cars and trucks (because they pay different rates), where they are in the garages,
how much money theyve made today As you leave the meeting, just for fun you take a moment to
sketch out a very quick diagram showing hierarchy and relationships for some of the major classes in the
system youve started imagining, based on the small amount very high-level info you have.
Draw that hierarchy. Remember, this is a brain dump on a napkin in a hall it doesnt have to be (in fact, it
cant be) perfect, extensive, or complete.

Nisarg Dave

10. Whats good about using a binary tree to find things? Whats the worst-case scenario with a binary
search tree?
Seaching, Insertion and Deletion can be managed efficiently because of its ability to
store keys in the nodes.
They are dynamic and have simple implementation.
The worst time complexity for Indexing, Inserstion, Deletion and Searching as well as
the worst Space Complexity is O(n).

vi

Você também pode gostar