Round 1:
First round was assignment kind of question where a word document was shared having below questions and I had to upload github repo for the same.
Question 1-NUMBER GENERATOR
Expectation:
1. Best design practices with modularity and class and type definitions , OO principles to be should
be followed;
2. Documentation to run the code
3. Relevant test cases
Question-1Write a spring boot application that maintains an Inventory of Employee data .
1. API to accept uploading of data as a flat file with line separated data
a. POST /api/employee?action=upload should accept a file
b. FILE CONTENT is lines of names and age – example
GANGULY 32
SACHIN TEND 44
c. The file may have upto 1000,000 data points
d. POST api to upload file should return a task identifying this processing
e. Task should have a get status API to track the completion success or failure of
the task
f. When the processing is done the data should be persisted in the database.
2. CRUD API for employee objects
Optional extension on Question -1 – Containerize the given spring boot app and deploy it to
a public cloud Kubernetes endpoint (Amazon ECS or Google Kubernetes Engine or any
other); Share the documentation on how to test the deployed app; or
Question 2 _Networks: For Both Backend and Full Stack
2.1Explain the concepts of Default Gateway in IP
2.2Explain the concepts of SNAT and DNAT
2.3
A.192.168.101.2/24
B.192.168.101.3/24
C.192.168.102.2/24
D.192.168.102.3/24
A,B,C,D are the IPs to be assigned to four computers ;
2.1What network elements are need to arrive at the above network architecture ; explain their
configurations in terms at L3/L2
Details of the IP assignments to be given to each node ;
2.4 - Explain ARP
Question 3 – UI – Mandatory For Full Stack, Optional for Backend
For Full Stack: UI Question in addition to the Spring App
Front End Question –
1. Create 2 screens, login and home screen.
2. Login screen should have username(email) and password(min length) field with login
button.
3. On entering valid entries login button should be enabled and submit action should take
user to home screen with welcome user message.
4. Angular features expected
a. Routing(login to home)
b. Field validators(login form error binding)
c. UserService component - Mock service to validate successful login
[Validate User function should check valid email and password of min length 6]
5. Add a readme content which has steps to run the UI.
6. NOTE –
c. Recommended to use latest Angular version(any version).
d. If no prior angular2+ experience, AngularJS 1.0 is also fine.I did upload the same on github and forwarded the link.
Round 2:
Question on Angular along with java theory and coding too.
Programing question 1:
To throw stack overflow exception. Look at baldung site for example
class Factorial {
public static int factor(int num) {
return num * factor(num-1);
}
public static void main(String[] args) {
try{
System.out.println(Factorial.factor(3));
// printCharCount("Hello World !!");
} catch(StackOverflowError e) {
e.printStackTrace();
}
}
}
Program on how to overcome stack overflow exception:
class Factorial {
public static int factor(int num) {
return num > 0 ? num * factor(num-1) : 1;
}
public static void main(String[] args) {
try{
System.out.println(Factorial.factor(3));
// printCharCount("Hello World !!");
} catch(StackOverflowError e) {
e.printStackTrace();
}
}
}Programing question 2:
Input:
// Hello World11!!!!
Output: To print count of each char, special character and numbers:
// H 1
// e 1
// l 3
// 1
//char count: , numCount: 2, SpecilaCharCount: 4
My Program:
import java.util.*;
public class CharCount {
public static void main(String[] args) {
printCharCount("Hello Wolrd!!!");
}
public static void printCharCount(String str) {
char[] charArr = str.toCharArray();
Map<Character, Integer> mp = new HashMap<>();
for (char c : charArr) {
if(!mp.containsKey(c)) {
mp.put(c, 1);
} else {
int count = mp.get(c);
mp.put(c, count+1);
}
}
Set<Map.Entry<Character, Integer>> set = mp.entrySet();
for (Map.Entry<Character, Integer> c : set) {
System.out.println(c.getKey() + ": "+c.getValue());
}
}
}Programing Question 3:
Input is given as File1.txt having below content.
Item1 10 20 30 15
Item2 5 12 45 60
WAP to write content of file to specific array or map and print.
My output:
File() {
File fr = new File("/user/File1.txt");
Scanner sc = new Scanner(fr);
while(sc.hasNextLine()) {
System.out.println(sc.nextLine());
}
}
//BufferedReader br = new BufferedReader(new InputStreamReader(file.getInputStream(), "UTF-8"));
Same day I got a confimation that I am selected from this round and was asked to scheduled next round.
Round 3:
Write a function to calculate sum of large number array in o(log n).
Two solution to this:
I gave solution slowly as this was bit tricky, as below:
public class Solution {
private static final long N = 10_000L;
public static void main(String[] args) {
long[] longArr = LongStream.generate(() -> (long) (Math.random() * 100)).limit(N).toArray();
long sum = sumOfNumbers(longArr);
System.out.println("Sum:: " + sum);
Thread t = new Thread(sum);
t.start();
}
private static long sumOfNumbers(long[] numbers) {
int size = 10;
long sum = Arrays.asList(numbers).stream().parallel().reduce(0, (a,b) -> (a+b));
return sum;
}
public class Sum implements Callable {
@Override
public void run() {
sum(number);
}
public long sum(long[] number) {
int i=0, j=numbers.length- 1;
while(i==j || i<j) {
sum += (numbers[i] + number[j]);
}
}
}