Aptitude And Technical Questions for ANSHIN SOFTWARE
Q. No. :
1
Question :
A bag contains 3 white, 5 blue and 4 green balls. If two balls are drawn at random from the bag, then find the probability that both the balls are of same colour?
A :
19/66
B :
18/66
C :
12/66
D :
17/66
Answer: A
Q. No. :
2
Question :
The odds in favour of a player being selected for the national team with three independent selectors are 4:3, 2:1 and 1:4 respectively. What is the probability that of the three selectors a majority will be favourable?
A :
2/5
B :
10/21
C :
6/35
D :
2/21
Answer: B
Q. No. :
3
Question :
In a right angled triangle, the larger of the sides containing the right angle is 8cm longer than the smaller of the sides. The sum of the lengths of the sides containing the right angle is 16cm more than the length of the other side. Find the length (in cm) of the smallest side.
A :
18
B :
12
C :
24
D :
16
Answer: C
Q. No. :
4
Question :
A person bought a certain number of oranges for Rs 7. If the prices of each orange was Rs 2 less, he would have bought 4 more oranges for the same amount. Find the number of oranges he bought originally.
A :
12
B :
10
C :
18
D :
15
Answer: B
Q. No. :
5
Question :
A test had 200 question. each correct answer carries 2 marks. each wrong answer carried (-1/2) marks and unanswered question carried no mark. Ajay attempted all the question in the test and scored 360 marks. What would his marks be, if for each correct answer he got only 1/2 mark and for each wrong answer he lost 2 marks?
A :
80
B :
100
C :
60
D :
120
Answer: C
Q. No. :
6
Question :
If Ashok travelled at 4/5 th of his usual speed, he would reach his destination 15 minutes late. By how much minutes would he be early if he travelled at 6/5 th of his usual speed?
A :
12
B :
10
C :
15
D :
16
Answer: B
Q. No. :
7
Question :
There are 30 mango trees, 40 guava trees and 50 apple trees. The trees are planted in such a way that each row of trees contains trees of the same variety and every row contains an equal number of trees. Find the minimum number of rows in which all the trees could be planted.
A :
9
B :
10
C :
11
D :
12
Answer: D
Q. No. :
8
Question :
Two men or 5 women can complete a piece of work in 15 days. In how many days can 4 men and 5 women complete the same work?
A :
7
B :
4
C :
6
D :
5
Answer: D
Q. No. :
9
Question :
Vijay plays a game, wherein he tosses a coin and scores 9 points if heads turns up and 5 points if tails turns up. A total of exactly 182 points is required to win the game. In how many combinations of heads and tails can Vijay win?
A :
6
B :
5
C :
4
D :
3
Answer: C
Q. No. :
10
Question :
The sum of present ages of a mother and her daughter is 60 years. When the mother attains her husband's present age, the ratio of her husband's age and her daughter's age would be 2:1. Find the present age of the daughter.
A :
15
B :
20
C :
10
D :
18
Answer: B
Q. No. :
11
Question :
publicclassMyRunnableimplementsRunnable
{publicvoid run()
{
// some code here
}
}
Because the class implements Runnable, an instance of it has to be passed to the Thread constructor, and then the instance of the Thread has to be started.
A is incorrect. There is no constructor like this for Runnable because Runnable is an interface, and it is illegal to pass a class or interface name to any constructor.
B is incorrect for the same reason; you can't pass a class or interface name to any constructor.
D is incorrect because MyRunnable doesn't have a start() method, and the only start() method that can start a thread of execution is the start() in the Thread class.
Q. No. :
12
Question :
public Object m()
{
Object o = new Float(3.14F);
Object [] oa = new Object[l];
oa[0] = o; /* Line 5 */
o = null; /* Line 6 */
oa[0] = null; /* Line 7 */return o; /* Line 8 */
}
When is the Float object, created in line 3, eligible for garbage collection?
Option A is wrong. This simply copies the object reference into the array.
Option B is wrong. The reference o is set to null, but, oa[0] still maintains the reference to the Float object.
Q. No. :
13
Question :
You need to store elements in a collection that guarantees that no
duplicates are stored and all elements can be accessed in natural order.
Which interface provides that capability?
Option B is correct. A set is a collection that contains no duplicate
elements. The iterator returns the elements in no particular order
(unless this set is an instance of some class that provides a
guarantee). A map cannot contain duplicate keys but it may contain
duplicate values. List and Collection allow duplicate elements.
Option A is wrong. A map is an object that maps keys to values. A map
cannot contain duplicate keys; each key can map to at most one value.
The Map interface provides three collection
views, which allow a map's contents to be viewed as a set of keys,
collection of values, or set of key-value mappings. The order of a map
is defined as the order in which the iterators on the map's collection
views return their elements. Some map implementations, like the TreeMap class, make specific guarantees as to their order (ascending key order); others, like the HashMap class, do not (does not guarantee that the order will remain constant over time).
Option C is wrong. A list is an ordered collection (also known as a
sequence). The user of this interface has precise control over where in
the list each element is inserted. The user can access elements by their
integer index (position in the list), and search for elements in the
list. Unlike sets, lists typically allow duplicate elements.
Option D is wrong. A collection is an ordered collection (also known
as a sequence). The user of this interface has precise control over
where in the list each element is inserted. The user can access elements
by their integer index (position in the list), and search for elements
in the list. Unlike sets, lists typically allow duplicate elements.
Q. No. :
14
Question :
What will be the output of the program?
int i = 1, j = 10;
do
{
if(i++ > --j) /* Line 4 */
{
continue;
}
} while (i < 5);
System.out.println("i = " + i + "and j = " + j); /* Line 9 */
This question is not testing your knowledge of the continue
statement. It is testing your knowledge of the order of evaluation of
operands. Basically the prefix and postfix unary operators have a higher
order of evaluation than the relational operators. So on line 4 the
variable i is incremented and the variable j is decremented before the greater than comparison is made. As the loop executes the comparison on line 4 will be:
if(i > j)
if(2 > 9)
if(3 > 8)
if(4 > 7)
if(5 > 6) at this point i is not less than 5, therefore the loop terminates and line 9 outputs the values of i and j as 5 and 6 respectively.
The continue statement never gets to execute because i never reaches a value that is greater than j.
If you put a finally block after a try and its associated catch
blocks, then once execution enters the try block, the code in that
finally block will definitely be executed except in the following
circumstances:
An exception arising in the finally block itself.
The death of the thread.
The use of System.exit()
Turning off the power to the CPU.
I suppose the last three could be classified as VM shutdown.
Q. No. :
16
Question :
Which cannot directly cause a thread to stop executing?
A :
Calling the SetPriority() method on a Thread object.
Option C is correct. notify() - wakes up a single thread that is waiting on this object's monitor.
Q. No. :
17
Question :
You want a class to have access to members of another class in the same package. Which is the most restrictive access that accomplishes this objective?
The only two real contenders are C and D. Protected
access Option C makes a member accessible only to classes in the same
package or subclass of the class. While default access Option D makes a
member accessible only to classes in the same package.
Q. No. :
18
Question :
Which two can be used to create a new Thread?
1.Extend java.lang.Thread and override the run() method. 2.Extend java.lang.Runnable and override the start() method. 3.Implement java.lang.Thread and implement the run() method. 4.Implement java.lang.Runnable and implement the run() method. 5.Implement java.lang.Thread and implement the start() method.
There are two ways of creating a thread; extend (sub-class) the Thread class and implement the Runnable interface. For both of these ways you must implement (override and not overload) the public void run() method.
(1) is correct - Extending the Thread class and overriding its run method is a valid procedure.
(4) is correct - You must implement interfaces, and runnable is an interface and you must also include the run method.
(2) is wrong - Runnable is an interface which implements not Extends. Gives the error: (No interface expected here)
(3) is wrong - You cannot implement java.lang.Thread (This is a Class). (Implements Thread, gives the error: Interface expected). Implements expects an interface.
(5) is wrong - You cannot implement java.lang.Thread (This is a class). You Extend classes, and Implement interfaces. (Implements Thread, gives the error: Interface expected)
Q. No. :
19
Question :
What is the name of the method used to start a thread execution?
Option B is Correct. The start() method causes this thread to begin execution; the Java Virtual Machine calls the run method of this thread.
Option A is wrong. There is no init() method in the Thread class.
Option C is wrong. The run() method of a
thread is like the main() method to an application. Starting the thread
causes the object's run method to be called in that separately executing
thread.
Option D is wrong. The resume() method is deprecated. It resumes a suspended thread.
Q. No. :
20
Question :
Which two of the following methods are defined in class Thread?
The usual method for using/importing the java packages/classes is by
using an import statement at the top of your code. However it is
possible to explicitly import the specific class that you want to use as
you use it which is shown in the code above. The disadvantage of this
however is that every time you create a new object you will have to use
the class path in the case "java.io" then the class name in the long run leading to a lot more typing.
Q. No. :
22
Question :
What will be the output of the program?
String s = "ABC";
s.toLowerCase();
s += "def";
System.out.println(s);
String objects are immutable. The object s above is set to "ABC". Now ask yourself if this object is changed and if so where - remember strings are immutable.
Line 2 returns a string object but does not change the originag string object s, so after line 2 s is still "ABC".
So what's happening on line 3? Java will treat line 3 like the following:
s = new StringBuffer().append(s).append("def").toString();
This effectively creates a new String object and stores its reference in the variable s, the old String object containing "ABC" is no longer referenced by a live thread and becomes available for garbage collection.
Q. No. :
23
Question :
Suppose that you would like to create an instance of a new Map that has an iteration order that is the same as the iteration order of an existing instance of a Map. Which concrete implementation of the Map interface should be used for the new instance?
A :
TreeMap
B :
HashMap
C :
LinkedHashmap
D :
The answer depends on the implementation of the existing instance.
The iteration order of a Collection is the order in which an iterator moves through the elements of the Collection. The iteration order of a LinkedHashMap is determined by the order in which elements are inserted.
When a new LinkedHashMap is created by passing a reference to an existing Collection to the constructor of a LinkedHashMap the Collection.addAll method will ultimately be invoked.
The addAll method uses an iterator to the existing Collection to
iterate through the elements of the existing Collection and add each to
the instance of the new LinkedHashMap.
Since the iteration order of the LinkedHashMap is determined by the order of insertion, the iteration order of the new LinkedHashMap must be the same as the interation order of the old Collection.
Q. No. :
24
Question :
Assume the following method is properly synchronized and called from a thread A on an object B:
wait(2000);
After calling this method, when will the thread A become a candidate to get another turn at the CPU?
A :
After thread A is notified, or after two seconds.
B :
After the lock on B is released, or after two seconds.
The Math.random() method returns a number greater than or equal to 0 and less than 1 . Since we can then be sure that the sum of that number and 2.5 will be greater than or equal to 2.5 and less than 3.5, we can be sure that Math.round() will round that number to 3. So Option B is the answer.
Q. No. :
26
Question :
What will be
output if you will execute following c code?
If time required to execute if loop is O(2) and the else part is O(2) then what will be the total execution time?
A :
O(2)
B :
O(4)
C :
O(3)
D :
None of these
Answer: A
Q. No. :
39
Question :
In an n-node binary tree traversal, what is the total number of steps required for a full traversal?
A :
n
B :
n-1
C :
2(n-1)
D :
2n
Answer: C
Q. No. :
40
Question :
Which of the following permutations can be obtained in the output (in the same order) using a stack assuming that the input is a sequence 1,2,3,4,5in that order?
A :
3,4,5,1,2
B :
3,4,5,2,1
C :
1,5,2,3,4
D :
5,4,3,1,2
Answer: B
Q. No. :
41
Question :
Suppose T is binary search tree. which of the following statements about T is TRUE?
A :
Preorder traversal of T will yield a sorted listing of the elements of T.
B :
Inorder traversal of T will yield a sorted listing of the elements of T.
C :
Postorder traversal of T will yield a sorted listing of the elements of T.
D :
Inorder traversal as well as Postorder traversal of T will yield a sorted listing the elements of T.
Answer: B
Q. No. :
42
Question :
Which of the following statements are correct? (i). A stack may be viewed as descending priority queue. (ii).A queue may be viewed as descending priority queue. (iii).A queue may be viewed as ascending priority queue. (iv).A stack may be viewed as ascending priority queue.
A :
(i), (ii)
B :
(i),(iii)
C :
(ii),(iv)
D :
(iii),(iv)
Answer: B
Q. No. :
43
Question :
When Inorder traversing a tree resulted E A C K F H D B G; the preorder traversal would return?
A :
F A E K C D B H G
B :
F A E K C D H G B
C :
E A F K H D C B G
D :
F E A K D C H B G
Answer: B
Q. No. :
44
Question :
Suppose that the internal bit string representation of a key is 010111001010110 and 5 bits are allowed in the index. What will be the hash value by using folding method?
A :
01111
B :
11110
C :
01011
D :
10101
Answer: A
Q. No. :
45
Question :
Suppose a relation has a degree of 7 and cardinality of 15. How many attributes(A) does this relation have and how many different rows (R) are currently present in the relation?
A :
A=7, R=15
B :
A=15, R=7
C :
A=6, R=14
D :
A=14, R=6
Answer: A
Q. No. :
46
Question :
In __________ strategy a transaction is not allowed to modify the physical database until the undo portion of the log is written to stable storage.
A :
centralized log
B :
write-back-log
C :
write-ahead-log
D :
None of these
Answer: C
Q. No. :
47
Question :
Consider the following functional dependencies in a database D -->A, A--> E, N-->R, R-->N, C-->Cn, C-->I (R,C)-->G The relation (R,N,D,A) is
A :
in 2NF but not in 3NF
B :
in 3NF but not in BCNF
C :
in BCNF
D :
None of these
Answer: A
Q. No. :
48
Question :
We have the following relation schemas : Patient(patient_name,patient_addr,Treating_doctor); Hospitalcharges(patient_name,hospitalchargeid,typeofcharge,amount); Doctorcharges(patient_name,doctorchargeid,typeofchargeid,amount) Suppose we have query as, (SELECT patient_name FROM doctorcharges) EXCEPTALL (SELECT patient_name FROM hospitalcharges) If Jones has 3 doctorcharge bill and 1 hospitalcharge bill, how many tuples with the name Jones in the result?
A :
4 tuples
B :
3 tuples
C :
2 tuples
D :
1 tuples
Answer: C
Q. No. :
49
Question :
Which of the following cannot be a triggering event for a trigger?
A :
INSERT
B :
DELETE
C :
UPDATE
D :
None of these
Answer: D
Q. No. :
50
Question :
State which of the following is True or False? (i). The value of NULL is ignored in any aggregation. (ii). NULL is treated as an ordinary value in a grouped attribute.