You are on page 1of 8

Date :

TECHNICAL TEST Name:


SOFTWARE ENGINEER Score:

Checked by:

ANSWER THE FOLLOWING QUESTIONS

1. Data Type Conversion [8]


Write a function HexToBin that takes a hex-string as an input and prints binary-string as an output. After
that, write a function BinToHex to decode it back. You might want to use Java functionality, or not.

private String HexToBin(String hexData){


// Insert your logic here

private String BinToHex(String binData){


// Insert your logic here

}
2. Algorithm [15]
The cost of a stock on each day is given in an array A []. Write a program to find the maximum profit one
can make by buying and selling in those days.
For example, if the given array is {100, 180, 260, 310, 40, 535, 695}, the maximum profit can earned by
buying on day 0, selling on day 3. Again buy on day 4 and sell on day 6. If the given array of prices is
sorted in decreasing order, then profit cannot be earned at all.
3. Multithreading [15]
There are two threads. Thread A reads incoming message from some entity. The message it is passing will
be consumed by thread B. The two threads communicate with each other through a standard Java socket.
By making use of methods in inter-threading communication in Java, explain how you will achieve this. If
possible, write a pseudo code or program to illustrate.

4. Java OOP [5]

Class A is a super class. Class B inherits class A, and overrides method test() from it. Two objects are
instantiated, and call test() method, as follow.
A obj1 = new B ( /* …. Some constructor here …. */);
B obj2 = new B ( /* …. Some constructor here ….. */); …………………………………………… ... (2)

obj1.test();
obj2.test();

What happen with the output? What is the difference if we change the line (2) with the following line:
A obj2 = new B (/* ….. Some constructor here ……*/)
5. String Operation [7]
Look for the following code snippet.

Class StringOperation{
public static void main (String[] args){
String str = “Alto”;
StringBuilder s2 = new StringBuilder(“Alto”);
StringBuffer s3 = new StringBuffer(“Alto”);

System.out.println(concat1(s1), concat2(s2), concat3(s3));


}

private static void concat1(String s1){


s1 = s1 + “Network”;
}

private static void concat2(StringBuilder s2){


s2.append(“Network”);
}
private static void concat2(StringBuffer s3){
s3.append(“Network”);
}
}

What’s the difference between those three? Which one should we use for passing message between threads?
Why?
6. SQL and Java [15]
You have an SQL database with name “MyDatabase” on DB server with address 202.128.48.56, port 2273.
The username to connect to DB is “user”, with password “mydb”.
There is a a “table1’ , which contains the following data:

merchant_code token_string expired_date bank_bin


character_varying (3) character_varying(40) timestamp without time [FK]
zone character_varying(6)

And another table “table2” with the following data:

bank_bin bank_code bank_name bank_status


[PK]character_varying character_varying(3) character varying character_varying(2)
(6)

A different token can be attributed to the same merchant and issuing bank. No same token can be attributed
to different merchant and or bank. When a new token is registered in the database, the previous token(s)
will be set as ‘expired’.
Suppose the program will take two inputs, merchant_code and bank_bin, to get the latest usable token from
the DB. Complete the following snippet Java code to do this step by step.
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class Tokenization {


public static String getToken(String merchant_code, String bank_bin){
// Complete your code here

}
}
7. Exception Handling [5]
What type of exceptions could Java program throws? Explain briefly and give example. Provide your code
snippet above with exception handling ability.

8. Java Collections [9]


1). What are the differences between HashMap & HashTable? In what case do you prefer one over another?

2). What are the differences between ArrayList & HashSet? In what case do you prefer one over the other?

3). Suppose you are developing new feature to map PAN-token in above database (Problem Set 6). A token
is unique to a PAN, but not the opposite, so in the program you would make use of token as a key and PAN
as its value. Its data mapping will be called between different threads inside the system when there is a
request for payment transaction. Between different Java Collection type, which one you would use to
implement the mapping and why?
9. Cryptography and Security [8]
1). What do you know about encipherment, encryption, hashing, and MAC? Provide each with one type of
algorithm you are familiar with.

2). Suppose you have to protect customer credit card number so that it cannot be stolen and or used by
unauthorized party. In problem 6, it is implemented by tokenizing PAN and save it in the DB. In this case,
which kind of encoding process you would implement to tokenize PAN?
10. Web Services [13]
1). There are couple ways to perform inter application communication through Web Services. One of which
is by Remote Procedure Call (ROC). It is used in old days before SOAP and REST API. What do you know
about this?
2). Suppose there are two different services running on different server, one acts as a client which passing
the customer data as follow.
name : Aji Pramono, account no : 1234567890, deduct amount : 100,000

The client service also sends method attribute as “DeductFund” to server’s service. The server will perform
some logic to eventually deduct the fund from customer balance. Write an XML RPC code to implement
above communication interchange, in both client and server sides.

You might also like