Interview Question for Jr. Software Engineers


Country: India
Interview Type: Written Test




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

I am posting the answer in Java code, Since i don' have Visual Studio installed, should work with little tweak in C#

public static void main(String[] args){

int[] a1 = {1, 2, 3, 4};
char[] a2 = {'a', 'b', 'c', 'd'};

List<String> L1 = new ArrayList<String>();

for(int i=0; i < a1.length; i++){
String tempInt = Integer.toString(a1[i]);
for(int j=0; j < a2.length; j++){
String tempChar = Character.toString(a2[j]);
if(i ==j){
L1.add(tempChar + tempInt);
}
}
}

Object[] a3 = L1.toArray();
for(Object o : a3){
System.out.println(o);
}
}

- naveen.km24 November 01, 2018 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

public static string[] Test(string[] a1, string[] a2)
        {
            int l = a1.Length;
            string[] a3 = new string[l];

            for (int i = 0; i < l; i++)
            {
                a3[i] = "" + a1[i] + a2[i];
            };

            return a3;
        }

- Anonymous November 26, 2018 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

public static string[] Test(string[] a1, string[] a2)
        {
            int l = a1.Length;
            string[] a3 = new string[l];

            for (int i = 0; i < l; i++)
            {
                a3[i] = "" + a1[i] + a2[i];
            };

            return a3;

}

- Anonymous November 26, 2018 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

This works fine here

public static string[] Test(string[] a1, string[] a2)
        {
            int l = a1.Length;
            string[] a3 = new string[l];

            for (int i = 0; i < l; i++)
            {
                a3[i] = "" + a1[i] + a2[i];
            };

            return a3;

}

- My answer November 26, 2018 | 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