Software Developer Intern Interview Questions in Boston, MA | Glassdoor

Software Developer Intern Interview Questions in Boston, MA

10

Software developer intern interview questions shared by candidates

Top Interview Questions

write a function that takes in an int and returns a string that would be how one would say that number (ex: 123 -> one hundred twenty three; 50019 -> five thousand nineteen).

3 Answers

import java.util.Scanner; import java.util.HashMap; /** * * @author Chepa */ public class prog2 { static HashMap h1 = new HashMap(); static HashMap h2 = new HashMap(); public static void main(String[] args){ Scanner s = new Scanner(System.in); System.out.println("Enter number "); int n = s.nextInt(); h1.put(1, "One"); h1.put(2, "Two"); h1.put(3, "Three"); h1.put(4, "Four"); h1.put(5, "Five"); h1.put(6, "Six"); h1.put(7, "Seven"); h1.put(8, "Eight"); h1.put(9, "Nine"); h1.put(10, "Ten"); h1.put(11, "Eleven"); h1.put(12, "Twelve"); h1.put(13, "Thirteen"); h1.put(14, "Fourteen"); h1.put(15, "Fifteen"); h1.put(16, "Sixteen"); h1.put(17, "Seventeen"); h1.put(18, "Eighteen"); h1.put(19, "Nineteen"); h2.put(2, "Twenty"); h2.put(3, "Thirty"); h2.put(4, "Fourty"); h2.put(5, "Fifty"); h2.put(6, "Sixty"); h2.put(7, "Seventy"); h2.put(8, "Eighty"); h2.put(9, "Ninety"); String output = getStringRepresentation(n); System.out.println("Output: " + output); } public static String getStringRepresentation(int n){ StringBuilder sb = new StringBuilder(); String temp; int x = n / 1000000; if(x > 0){ temp = getStringFor3Digits(x); sb.append(temp).append(" Million"); } n = n % 1000000; x = n / 1000; if (x > 0){ System.out.println("For thousand x = " + x); temp = getStringFor3Digits(x); sb.append(" ").append(temp).append(" Thousand"); } n = n % 1000; if(n > 0){ temp = getStringFor3Digits(n); sb.append(" ").append(temp); } return sb.toString(); } public static String getStringFor3Digits(int n){ StringBuilder sb = new StringBuilder(); int x = n / 100; if(x > 0){ System.out.println("In hundred x = " + x + " " + h1.get(x)); sb.append(h1.get(x)).append(" Hundred"); } n = n % 100; if (n 0){ sb.append(" ").append(h2.get(x)); } n = n % 10; if(n > 0) sb.append(" ").append(h1.get(n)); } return sb.toString(); } }

def numberReader(x): words = "" numbers = { 0: "", 1: "One ", 2: "Two ", 3: "Three ", 4: "Four ", 5: "Five ", 6: "Six ", 7: "Seven ", 8: "Eight ", 9: "Nine ", 10: "Ten ", 11: "Eleven ", 12: "Twelve ", 13: "Thirteen ", 14: "Fourteen ", 15: "Fifteen ", 16: "Sixteen ", 17: "Seventeen ", 18: "Eighteen ", 19: "Nineteen ", 20: "Twenty ", 30: "Thirty ", 40: "Forty ", 50: "Fifty ", 60: "Sixty ", 70: "Seventy ", 80: "Eighty ", 90: "Ninty " } ln = len(str(x)) strx = str(x) if x 20 and x = 4 and ln 6 and ln 9 and ln <= 12: words += numberReader(int(strx[:ln-9])) + "Billion " + numberReader(int(strx[-9:])) return words.capitalize()

I think you didn't take in consideration the fact that an int can be a negative number. For example in python sript len(str(abs(x))) would give you the result you wanted. Cause minus would give higher length.

1. How do you test a key board? 2. Given nine items and one of them is heavier than the others, how do you find the heavier one using a scale just twice?

1 Answer

Not so difficult questions if you are well versed with object oriented programing

Given all the resources and time in the world what will you develop, please note you need to be innovative?

1 Answer

Given two robots on an infinite line of integers, with a flag guaranteed to be between them, write a behavior for both robots to follow which will guarantee them to eventually meet. The robots can only "see" the position they are standing on, and can't remember anything. Also note that they can't tell if they are the leftmost or rightmost robot. They can tell if they are on the flag or the other robot. They may move right, move left, or wait.

1 Answer

Write an integer-to-string function in C++.

1 Answer

difference between abstract class and interface

1 Answer

describe different data structures and its complexities .