Java Developer Technical Aptitude Battery ISC - Fernando I Solórzan o R.
Java Developer Technical Aptitude Battery ISC - Fernando I Solórzan o R.
1
Java IDE Productivity Software
O Rational Architect Developer O Adobe Dreamweaver
O Websphere Studio Application Developer O Adobe Flash
O BEA WebLogic O Adobe Fireworks
O SunOne Studio O Adobe Photoshop CS
O Borland JBuilder O Adobe InDesign
O Netbeans O Adobe PageMill
O Gel O Microsoft Office 2000, XP, 2003
O J++ O Microsoft Visual Studio
O Visual Age for Java O Other ________________
O Eclipse
O Other ____IntelliJ IDEA __________
2
1. Which of these primitive data types are arranged in size from smallest to greatest?
a. byte, char, int, float, long
b. Boolean, int, Long, double, BigDecimal
c. Char, Integer, String
d. int, float, long, double
e. None of the above
3
6. Is there an error in this code?
HashMap<String, Long> HM = new HashMap<String, Long>();
HM.put("Time", System.currentTimeMillis());
HM.put(Integer.valueOf(10), Long.valueOf("112012912912"));
a. Code does not compile because of different arguments in the “put” method
b. The HashMap is null and will throw an exception when putting elements into it
c. No errors
System.out.println(factorial(6));
a. java.lang.ArithmeticException: / by zero
b. 32768.0
c. 720.0
d. Code does not compile
e. java.lang.IllegalArgumentException
8. Explain what each access modifier does to a class, method, and/or variable:
4
data member – It is said to be having the is said to be having
said to be having the default access the default access
default access modifier by default. modifier by default.
modifier by default.
The data members, class or The data members, class
The data members, methods which are not or methods which are not
class or methods declared using any access declared using any access
which are not modifiers i.e. having default modifiers i.e. having default
declared using any access modifier are accessible access modifier are
access modifiers i.e. only within the same package accessible only within the
having default access same package
modifier are
accessible only within
the same package
The final keyword in java is used to restrict the user. The java final keyword can be used in many context. Final
can be:
1. variable
2. method
3. class
If you make any variable as final, you cannot change the value of final variable(It will be constant).
b. static
The static keyword belongs to the class than an instance of the class.
Block
Nested class
The static variable can be used to refer to the common property of all objects (which is not unique for each
object), for example, the company name of employees, college name of students, etc.
The static variable gets memory only once in the class area at the time of class loading.
If you apply static keyword with any method, it is known as static method.
A static method belongs to the class rather than the object of a class.
A static method can be invoked without the need for creating an instance of a class.
A static method can access static data member and can change the value of it.
6
Is used to initialize the static data member.
c. Synchronized
Multi-threaded programs may often come to a situation where multiple threads try to access the same resources
and finally produce erroneous and unforeseen results.
So it needs to be made sure by some synchronization method that only one thread can access the resource at a
given point of time.
Java provides a way of creating threads and synchronizing their task by using synchronized blocks. Synchronized
blocks in Java are marked with the synchronized keyword. A synchronized block in Java is synchronized on some
object.
All synchronized blocks synchronized on the same object can only have one thread executing inside them at a time.
All other threads attempting to enter the synchronized block are blocked until the thread inside the synchronized
block exits the block.
d. Native
The native keyword is applied to a method to indicate that the method is implemented in native code using JNI
(Java Native Interface). native is a modifier applicable only for methods and we can’t apply it anywhere else. The
methods which are implemented in C, C++ are called as native methods or foreign methods.
e. transient
transient is a variables modifier usetransient is a variables modifier used in serialization. At the time of
serialization, if we don’t want to save value of a particular variable in a file, then we use transient keyword.
When JVM comes across transient keyword, it ignores original value of the variable and save default value
of that variable data type.
transient keyword plays an important role to meet security constraints. There are various real-life examples
where we don’t want to save private data in file. Another use of transient keyword is not to serialize the
variable whose value can be calculated/derived using other serialized objects or system such as age of a
person, current date, etc.
Practically we serialized only those fields which represent a state of instance, after all serialization is all
about to save state of an object to a file. It is good habit to use transient keyword with private confidential
fields of a class during serialization.
f. volatile
7
Using volatile is yet another way (like synchronized, atomic wrapper) of making class thread safe. Thread
safe means that a method or class instance can be used by multiple threads at the same time without any
problem.
12. Fill the truth table below with the corresponding values
14. When using the “read committed” transaction isolation level, what errors may occur? (check all that
apply)
a. The results may include phantom data
b. A deadlock may occur with high concurrency
c. This transaction isolation level seldom causes errors
d. A non-repeatable read may occur
e. None of the above
15. What is the superclass of all exceptions and errors in the java language?
a. java.lang.Error
b. java.lang.Exception
c. java.lang.Throwable
d. java.lang.RuntimeException
e. None of the above
8
17. Given the following 2x2 Matrix create a method that computes the determinant of this Matrix given by
the formula ad-cb, ∀ a,b,c,d ∈ R.
18. A vector V in the Cartesian plane centered at the origin with endpoints (x, y) has a magnitude r and a direction θ
where r = √(x2 + y2) and θ = Tan-1(y/x) (the angle between the vector and the x-axis). Given a vector A with
magnitude r1 and direction θ 1 and a vector B with magnitude r2 and direction θ 2, create a method that takes two
vectors and tests to see if both vectors are identical. If both vectors are identical, the method returns true, otherwise
it returns false.
19. Create a method that utilizes a brute-force algorithm to find and print the first 10 numbers that satisfy Pythagoras’
Theorem such that c 2 = a2 + b2, ∀ a,b,c ∈ Z
20. Create a method that implements the Fundamental Theorem of Calculus such that for any given function
F(x) = ∫f´(x) dx we can find the value for F(x) = ∫abf´(x) dx. For this, we assume that f´(x) = 2x2 and F(x) = (2/3)x3
and that F(x) = F(b)-F(a) ∀ a,b ∈ R. Create a function that takes in a and b as floating-point numbers and computes
the integral F(x) = ∫abf´(x) dx.
9
21. Define join and name different type of joins?
A SQL join is a Structured Query Language (SQL) instruction to combine data from two sets of data (i.e. two tables).
(INNER) JOIN: Returns records that have matching values in both tables
LEFT (OUTER) JOIN: Returns all records from the left table, and the matched records from the right table
RIGHT (OUTER) JOIN: Returns all records from the right table, and the matched records from the left table
FULL (OUTER) JOIN: Returns all records when there is a match in either left or right table
22. Is it possible for a table to have more than one foreign key?
In addition to the primary key, a table can have zero or more foreign keys, which are columns that reference the
primary keys of other tables.
Variable table (DECLARE @t TABLE) are only visible to the connection that is created and are removed when the
batch or stored procedure ends. display: inline-block; width: 336px; height: 280px "data-ad-client =" ca-pub-
4860592551209305 "data-ad-slot =" 4807115270 "data-adsbygoogle-status =" done ">
Local temporary tables (CREATE TABLE #t) are only visible to the connection that is created and are removed when
the connection is closed.
Global temporary tables (CREATE TABLE ## t) are visible to everyone, and are cleared when all connections
referenced to them have been closed.
Tempdb persistent tables (USE tempdb CREATE TABLE t) are visible to everyone, and are removed when the server
is restarted.
DROP removes existing objects in a database. If it is a table, the table with all its records will be dropped.
TRUNCATE removes ALL records from a table, think it's like "Initializing" the table, resetting it to zero.
TRUNCATE has some important differences with DELETE. TRUNCATE removes all records, with no possibility of
filtering or setting conditions.
26. What keyword does an SQL SELECT statement use for a string search?
select *
from EMPLEADOS
where APELLIDOS like 'R%'
SELECT count(*) AS total FROM orders; SELECT count(*) AS cust_123_total FROM orders WHERE customer_id = '123';
+-------+ +----------------+
| total | | cust_123_total |
+-------+ +----------------+
| 100 | | 15 |
+-------+ +----------------+
Given the above query results, what will be the result of the query below?
AS cust_not_123
85
11
28. Given a table TBL with a field Nmbr that has rows with the following values:
1, 0, 0, 1, 1, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1
29. Write a SQL query to find the 10th highest employee salary from an Employee table. Explain your
answer.
(Note: You may assume that there are at least 10 records in the Employee table.)
30. Given a table dbo.users where the column user_id is a unique identifier, how can you efficiently select
the first 100 odd user_id values from the table?
(Assume the table contains well over 100 records with odd user_id values.)
SELECT *
FROM (
SELECT *
FROM dbo.users
ORDER BY user_id DESC
)
WHERE rownum <= 100
13