Java Test – Junior Developer
Full Name
Date
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 Programming
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 = [Link] / 2;
int number;
int index;
for(int a = 0;a < [Link]; a++){
if(a < paramLength){
index = [Link] - 1 - a;
number = p[index];
p[index] = p[a];
p[a] = number;
}
[Link](p[a] + ";");
}
}
}
Expected Output:-
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};
[Link]("The value is " + removeDuplicate(numbers));
}
public static String removeDuplicate (int[] p)
{
//complete your program here
Expected Output:-
The value is 1,2,3,4,5,6,8
Test 3: Java Programming
Write Java code to be able to print below result:
1. Loop an integer value from 1 to 50
2. If the value modulus 3 == 0 then ONLY print “H”
3. If the value modulus 5 == 0 then ONLY print “E”
4. If the value modulus 3 == 0 AND value modulus 5 == 0 then ONLY print “HE”
5. If not meet above condition, just print the value
Expected output:
1
2
H
4
E
H
7
8
H
E
11
H
13
14
HE
16
17
18
19
E
…
Test 4: SQL Query
Given 2 tables below:-
STUDENT_TABLE
STUDENT_CODE FIRST_NAME DOB CITY COUNTRY
STUD001 Gavin 12-09-1996 KUALA MALAYSIA
LUMPUR
STUD002 Malvina 04-02-1997 PETALING MALAYSIA
JAYA
STUD003 Wendy 28-11-1996 GEORGE MALAYSIA
TOWN
STUD004 Rex 31-08-1997 BANGKOK THAILAND
SCORE_TABLE
STUDENT_CODE SUBJECT SCORE TRAINING_DATE
STUD002 JAVA 100 2019-01-02
STUD001 C++ 99 2019-01-03
STUD002 SQL 60 2019-01-02
STUD004 JAVA 78 2019-01-02
STUD001 JAVA 88 2019-01-03
STUD001 SQL 90 2019-01-03
STUD004 SQL 78 2019-01-02
STUD003 SQL 88 2019-01-02
Write a query to get the list of students from Malaysia who took JAVA subject and order
from the most recent training date to oldest date.
Expected Output:-
STUDENT_CODE SUBJECT SCORE TRAINING_DATE
STUD001 JAVA 88 2019-01-03
STUD002 JAVA 100 2019-01-02