JAVA Exam

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

Java Time : 1 Day

1. I mpl ement t he f ol l owi ng f unct i on


public static int sumOfTwoLargestElements(int[] a) {
/*
Please implement this method to return the sum of the
two largest integer numbers in a given array.
*/
}


2. I mpl ement t he f ol l owi ng f unct i on
public static int getClosestToZero(int[] a) {
/*
Please implement this method to return the integer number in a
given array that is closest to zero.
If there are two equally closest to zero elements like 2 and -2
consider the positive element, i.e. 2, to be "closer" to zero.
*/
}


3. Wr i t e a J ava pr ogr amt o l i st out t he first 1500 natural numbers
whose f act or ( s) i s/ ar e ei t her ONLY 2, 3, or 5. The f ast er your pr ogr am
can compl et e t he cal cul at i on t he bet t er , but i t shoul d not r un mor e
t han 2 minute.

For your r ef er ence, t he f i r st 20 number s ar e ( f act or s l i st ed af t er
semi col on) :

2 : 2
3 : 3
4 : 2 2
5 : 5
6 : 2 3
8 : 2 2 2
9 : 3 3
10 : 2 5
12 : 2 2 3
15 : 3 5
16 : 2 2 2 2
18 : 2 3 3
20 : 2 2 5
24 : 2 2 2 3
25 : 5 5
27 : 3 3 3
30 : 2 3 5
32 : 2 2 2 2 2
36 : 2 2 3 3
40 : 2 2 2 5

PS: 21 (3*7), 22 (2*11), 26 (2*13) are numbers that should not be in
the list.
SQL
1. Quest i on 2 & 3 wi l l based on t he f ol l owi ng t abl e schema:
or der _i d NUMBER
cust omer _name VARCHAR
or der _dat e DATE
quant i t y NUMBER
2. Pl ease wr i t e a SQL quer y t o sear ch f or t he l at est or der wi t h
quant i t y l ar ger t han X.
3. Pl ease wr i t e a SQL quer y t o l i st down f or each cust omer how many
or der s t hey have made r espect i vel y.

You might also like