0% found this document useful (0 votes)
30 views

Software Engineer - Java Test

The document contains instructions for two coding exercises. Section 1 describes a function that takes an array as input and returns the distance between the two closest numbers. Section 2 provides guidelines for building a basic Spring Boot application with REST APIs for performing CRUD operations on User and Order objects that have a one-to-many relationship. The completed work is to be compressed and submitted as a single folder containing the Main.java file from Section 1 and the Spring Boot project from Section 2.

Uploaded by

Mawar Lia
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views

Software Engineer - Java Test

The document contains instructions for two coding exercises. Section 1 describes a function that takes an array as input and returns the distance between the two closest numbers. Section 2 provides guidelines for building a basic Spring Boot application with REST APIs for performing CRUD operations on User and Order objects that have a one-to-many relationship. The completed work is to be compressed and submitted as a single folder containing the Main.java file from Section 1 and the Spring Boot project from Section 2.

Uploaded by

Mawar Lia
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Section 1

Create a Main.java file and implement the following function.

From a given array of natural numbers, return the distance between the two closest numbers.

import java.util.*;

public class Main {

// Returns the distance between the two closest numbers.


static int distanceClosestNumbers(int[] numbers) {
// Code here
}

public static void main(String[] args) {


int[] a= {2, 9, 40, 15, 84, 7,83, 35};
System.out.println(distanceClosestNumbers(a));
// Expected result is 1 (the 2 closest numbers are 84 and 83)
}
}

Section 2

Tech Stacks: Java Spring Boot + MySql/MongoDB (Choose one)

Go to Spring Initializr (https://start.spring.io/) for your starter template. Add Spring Web MVC
and any required dependency.

User
1. Create a User object class which has a name, phone number, age, gender and
nationality.
2. Create a controller with a few REST Api as listed below:
○ Create user
○ Get all users
○ Get user by name/id
○ Update user
○ Delete user

Order
1. Create an Order object class which has an id, buyer (user), total and paid at.
2. Create a controller with a few REST Api as listed below:
○ Get all orders
○ Get order by id
○ Create order
○ Update order
○ Delete order

Extra
1. Make a REST Api to get orders by user
2. Make a REST Api to get total orders by user

You may test the API by using any HTTP client (preferably Postman)

How to submit:
Compress a folder with the Main.java file (Section 1) and the Java Spring Boot project (Section
2)

You might also like