Java Test
Full Name Sunil Shrivastav
Date 8-March-2021
Note:
• Allocated Time: 1 hour
• We tolerate minor syntax issue as this is written test. What we want to see is your
logic.
Test 1: Java Basic
What is the expected output of the following program?
public class MyClass {
public static void main(String args[]) {
int[] numbers = {1,7,2,4,8,5};
sequencingNumbers(numbers);
}
public static void sequencingNumbers (int ... p){
int paramLength = p.length / 2;
int number;
int index;
for(int a = 0;a < p.length; a++){
if(a < paramLength){
index = p.length - 1 - a;
number = p[index];
p[index] = p[a];
p[a] = number;
}
System.out.print(p[a] + ";");
}
}
}
Expected Output:-
Method sequencingNumbers is having space in between parameter so below are the possibility of output
1. If parameter type is int P then there will be compilation error.
2. If parameter type is int [ ] P then output will be 5;8;4;2;7;1;
Test 2: Java Programming
Complete the Java function below to removing the duplicates from the array
public static void main(String[] args)
{
int[] numbers = {1, 2, 3, 4, 4, 4, 4, 4, 5, 5, 5, 6, 5, 5, 5, 5, 5, 8};
System.out.print("The value is " + removeDuplicate(numbers));
}
public static String removeDuplicate (int[] p)
{
//complete your program here
Set<Integer> mySet = new HashSet <Integer>();
for(int number : p)
{
mySet.add(number);
return mySet.toString();
Expected Output:-
The value is 1,2,3,4,5,6,8
Test 3: SQL Query
Given 2 tables below:-
EMPLOYEE_TABLE
EMP_CODE FIRST_NAME START_WORKING_DATE PROJECT_CODE
EMP001 Gavin 12-09-2016 CR
EMP002 Malvina 04-02-2017 MD
EMP003 Wendy 28-11-2016
EMP004 Rex 31-08-2015 CR
EMP005 Luna 18-03-2015 BT
PROJECT_TABLE
PROJECT_CODE PROJECT_NAME BASE_COUNTRY
CR CIMB RCS MALAYSIA
MD MBB DTB INDONESIA
BT BTMU SINGAPORE
Write a query to get the list of employees who work for a project in Malaysia OR unassign to
any project sort by employee code in ascending.
Expected Output:-
EMPLOYEE PROJECT START_WORKING_DATE
EMP001 CIMB RCS 12-09-2016
EMP003 28-11-2016
EMP004 CIMB RCS 31-08-2015
SELECT A.EMP_CODE AS EMPLOYEE, B.PROJECT_NAME AS PROJECT, A.START_WORKING_DATE
FROM EMPLOYEE A LEFT JOIN PROJECT_TABLE B
ON B.PROJECT_CODE = A.PROJECT_CODE
WHERE B.BASE_COUNTRY = 'MALAYSIA' OR B.PROJECT_CODE IS NULL
Test 4: Web API Services Design
Given requirements:
- Create a Back Office maintenance module that can administrate (Add / Update / Delete)
project information.
- The Enquiry Screen shall list out the resources under the selected project.
Sample Screen Designs:
Please draft the DB tables design and list of RESTful Web API services accordingly.
Tip: Example of a REST Web API service: GET - /v1/project/{id} - To get single project details data.
CREATE TABLE tbl_project_maintenance (
CREATE TABLE tbl_resource ( CREATE TABLE tbl_project ( resource_name ...,
Id int IDENTITY(1,1) Not Null, project_Id int IDENTITY(1,1) Not Null, project_name....,
first_name varchar (50), project_name varchar (50), project_startdate....,
last_name varchar(50), project_module_name varchar(50), project_enddate....,
address varchar (100), project manager varchar (100) project_role....,
date_ofbirth smalldatetime, ) .......
handphone (11), .....
email_id (100), )
Contraint PK_tbl_resource
PRIMARY KEY Id ASC
)
Add a new project to list - POST ([url:port]/project/post -d "projectName":"MicroserviceProject (phase1)","projectModuleName":"HEB","ProjectManager": "John Doe")
add rerouces : POST ([url:port]/project/post -d "First Name":................")
get resource details : GET ([url:port]/employees/search/?firstName=ABC
Test 5: Spring Boot Framework
Based on the requirements given in Test #4, please design the Spring MVC / Spring Boot
application project structure, e.g. folder / package structure, with some classes, resources
file(s), config file(s), Maven/Gradle file(s), etc., whatever applicable.
The coding content is not required, but please try to list out as many as possible the Spring
annotations that might be used in the applicable classes, e.g. JPA Entity classes would use
@Entity and @Table.
You are encouraged to add in additional library, design considerations or explanation with
diagrams or writings, as long as you believe those are useful stuff, in order to showcase your
experience and understanding about development base of RESTful Web API application
using Spring / Spring Boot framework. We will further discuss based on your answer during
the face to face interview.