Synapse Techno Design Innovations Private Limited ( CALL BASED 2018 BATCH )

Synapse Techno Design Innovations Private Limited ( CALL BASED 2018 BATCH )

2018 BATCH ONLY

Address: Prestige Shantineketan, 8th Floor, Tower `C` Commercial Complex, Gate No. 2, Near ITPL, Whitefield Main Road, Bengaluru, Karnataka 560066

Time and Distance
Time and Work
Compound Interest
Partnership
Problems on Ages
Clock
Area
Permutation and Combination
Problems on Numbers

1.
A person crosses a 600 m long street in 5 minutes. What is his speed in km per hour?

A. 3.6
B. 7.2
C. 8.4
D. 106.
In a flight of 600 km, an aircraft was slowed down due to bad weather. Its average speed for the trip was reduced by 200 km/hr and the time of flight increased by 30 minutes. The duration of the flight is:

A. 1 hour
B. 2 hours
C. 3 hours
D. 4 hours
View Answer Discuss in Forum Workspace Report
7.
A man complete a journey in 10 hours. He travels first half of the journey at the rate of 21 km/hr and second half at the rate of 24 km/hr. Find the total journey in km.

A. 220 km
B. 224 km
C. 230 km
D. 234 km
View Answer Discuss in Forum Workspace Report
8.
The ratio between the speeds of two trains is 7 : 8. If the second train runs 400 km in 4 hours, then the speed of the first train is:

A. 70 km/hr
B. 75 km/hr
C. 84 km/hr
D. 87.5 km/hr
View Answer Discuss in Forum Workspace Report
9.
A man on tour travels first 160 km at 64 km/hr and the next 160 km at 80 km/hr. The average speed for the first 320 km of the tour is:

A. 35.55 km/hr
B. 36 km/hr
C. 71.11 km/hr
D. 71 km/hr
View Answer Discuss in Forum Workspace Report
10.
A car travelling with of its actual speed covers 42 km in 1 hr 40 min 48 sec. Find the actual speed of the car.

A.
17 6 km/hr
7
B. 25 km/hr
C. 30 km/hr
D. 35 km/hr
2.

From a group of 7 men and 6 women, five persons are to be selected to form a committee so that at least 3 men are there on the committee. In how many ways can it be done?

A. 564
B. 645
C. 735
D. 756
E. None of these
View Answer Discuss in Forum Workspace Report
2.
In how many different ways can the letters of the word ‘LEADING’ be arranged in such a way that the vowels always come together?

A. 360
B. 480
C. 720
D. 5040
E. None of these
View Answer Discuss in Forum Workspace Report
3.
In how many different ways can the letters of the word ‘CORPORATION’ be arranged so that the vowels always come together?

A. 810
B. 1440
C. 2880
D. 50400
E. 5760
View Answer Discuss in Forum Workspace Report
4.
Out of 7 consonants and 4 vowels, how many words of 3 consonants and 2 vowels can be formed?

A. 210
B. 1050
C. 25200
D. 21400
E. None of these
View Answer Discuss in Forum Workspace Report
5.
In how many ways can the letters of the word ‘LEADER’ be arranged?

A. 72
B. 144
C. 360
D. 720
E. None of these

6.
In a group of 6 boys and 4 girls, four children are to be selected. In how many different ways can they be selected such that at least one boy should be there?

A. 159
B. 194
C. 205
D. 209
E. None of these
View Answer Discuss in Forum Workspace Report
7.
How many 3-digit numbers can be formed from the digits 2, 3, 5, 6, 7 and 9, which are divisible by 5 and none of the digits is repeated?

A. 5
B. 10
C. 15
D. 20
View Answer Discuss in Forum Workspace Report
8.
In how many ways a committee, consisting of 5 men and 6 women can be formed from 8 men and 10 women?

A. 266
B. 5040
C. 11760
D. 86400
E. None of these
View Answer Discuss in Forum Workspace Report
9.
A box contains 2 white balls, 3 black balls and 4 red balls. In how many ways can 3 balls be drawn from the box, if at least one black ball is to be included in the draw?

A. 32
B. 48
C. 64
D. 96
E. None of these
View Answer Discuss in Forum Workspace Report
10.
In how many different ways can the letters of the word ‘DETAIL’ be arranged in such a way that the vowels occupy only the odd positions?

A. 32
B. 48
C. 36
D. 60
E. 120

The ratio between the length and the breadth of a rectangular park is 3 : 2. If a man cycling along the boundary of the park at the speed of 12 km/hr completes one round in 8 minutes, then the area of the park (in sq. m) is:

A. 15360
B. 153600
C. 30720
D. 307200
View Answer Discuss in Forum Workspace Report
2.
An error 2% in excess is made while measuring the side of a square. The percentage of error in the calculated area of the square is:

A. 2%
B. 2.02%
C. 4%
D. 4.04%
View Answer Discuss in Forum Workspace Report
3.
The ratio between the perimeter and the breadth of a rectangle is 5 : 1. If the area of the rectangle is 216 sq. cm, what is the length of the rectangle?

A. 16 cm
B. 18 cm
C. 24 cm
D. Data inadequate
E. None of these
View Answer Discuss in Forum Workspace Report
4.
The percentage increase in the area of a rectangle, if each of its sides is increased by 20% is:

A. 40%
B. 42%
C. 44%
D. 46%
View Answer Discuss in Forum Workspace Report
5.
A rectangular park 60 m long and 40 m wide has two concrete crossroads running in the middle of the park and rest of the park has been used as a lawn. If the area of the lawn is 2109 sq. m, then what is the width of the road?

A. 2.91 m
B. 3 m
C. 5.82 m
D. None of these

1. Which two method you need to implement for key Object in HashMap ?
In order to use any object as Key in HashMap, it must implements equals and hashcode method in Java. Read How HashMap works in Java for detailed explanation on how equals and hashcode method is used to put and get object from HashMap.

2. What is immutable object? Can you write immutable object?Immutable classes are Java classes whose objects can not be modified once created. Any modification in Immutable object result in new object. For example is String is immutable in Java. Mostly Immutable are also final in Java, in order to prevent sub class from overriding methods in Java which can compromise Immutability. You can achieve same functionality by making member as non final but private and not modifying them except in constructor.

3. What is the difference between creating String as new() and literal?
When we create string with new() Operator, it’s created in heap and not added into string pool while String created using literal are created in String pool itself which exists in PermGen area of heap.

String s = new String(“Test”);

does not put the object in String pool , we need to call String.intern() method which is used to put them into String pool explicitly. its only when you create String object as String literal e.g. String s = “Test” Java automatically put that into String pool.

4. What is difference between StringBuffer and StringBuilder in Java ?

Classic Java questions which some people thing tricky and some consider very easy. StringBuilder in Java is introduced in Java 5 and only difference between both of them is that Stringbuffer methods are synchronized while StringBuilder is non synchronized. See StringBuilder vs StringBuffer for more differences.

5. Write code to find the First non repeated character in the String ?
Another good Java interview question, This question is mainly asked by Amazon and equivalent companies. See first non repeated character in the string : Amazon interview question

6. What is the difference between ArrayList and Vector ?
This question is mostly used as a start up question in Technical interviews on the topic of Collection framework . Answer is explained in detail here Difference between ArrayList and Vector .

7. How do you handle error condition while writing stored procedure or accessing stored procedure from java?
This is one of the tough Java interview question and its open for all, my friend didn’t know the answer so he didn’t mind telling me. my take is that stored procedure should return error code if some operation fails but if stored procedure itself fail than catching SQLException is only choice.

8. What is difference between Executor.submit() and Executer.execute() method ?
There is a difference when looking at exception handling. If your tasks throws an exception and if it was submitted with execute this exception will go to the uncaught exception handler (when you don’t have provided one explicitly, the default one will just print the stack trace to System.err). If you submitted the task with submit any thrown exception, checked exception or not, is then part of the task’s return status. For a task that was submitted with submit and that terminates with an exception, the Future.get will re-throw this exception, wrapped in an ExecutionException.

9. What is the difference between factory and abstract factory pattern?
Abstract Factory provides one more level of abstraction. Consider different factories each extended from an Abstract Factory and responsible for creation of different hierarchies of objects based on the type of factory. E.g. AbstractFactory extended by AutomobileFactory, UserFactory, RoleFactory etc. Each individual factory would be responsible for creation of objects in that genre.
You can also refer What is Factory method design pattern in Java to know more details.

10. What is Singleton? is it better to make whole method synchronized or only critical section synchronized ?
Singleton in Java is a class with just one instance in whole Java application, for example java.lang.Runtime is a Singleton class. Creating Singleton was tricky prior Java 4 but once Java 5 introduced Enum its very easy. see my article How to create thread-safe Singleton in Java for more details on writing Singleton using enum and double checked locking which is purpose of this Java interview question.

11. Can you write critical section code for singleton?
This core Java question is followup of previous question and expecting candidate to write Java singleton using double checked locking. Remember to use volatile variable to make Singleton thread-safe.

12. Can you write code for iterating over hashmap in Java 4 and Java 5 ?
Tricky one but he managed to write using while and for loop.

13. When do you override hashcode and equals() ?
Whenever necessary especially if you want to do equality check or want to use your object as key in HashMap.

14. What will be the problem if you don’t override hashcode() method ?
You will not be able to recover your object from hash Map if that is used as key in HashMap.
See here How HashMap works in Java for detailed explanation.

15. Is it better to synchronize critical section of getInstance() method or whole getInstance() method ?
Answer is critical section because if we lock whole method than every time some one call this method will have to wait even though we are not creating any object)

16. What is the difference when String is gets created using literal or new() operator ?
When we create string with new() its created in heap and not added into string pool while String created using literal are created in String pool itself which exists in Perm area of heap.

17. Does not overriding hashcode() method has any performance implication ?
This is a good question and open to all , as per my knowledge a poor hashcode function will result in frequent collision in HashMap which eventually increase time for adding an object into Hash Map.

18. What’s wrong using HashMap in multithreaded environment? When get() method go to infinite loop ?
Another good question. His answer was during concurrent access and re-sizing.

19. What do you understand by thread-safety ? Why is it required ? And finally, how to achieve thread-safety in Java Applications ?

Java Memory Model defines the legal interaction of threads with the memory in a real computer system. In a way, it describes what behaviors are legal in multi-threaded code. It determines when a Thread can reliably see writes to variables made by other threads. It defines semantics for volatile, final & synchronized, that makes guarantee of visibility of memory operations across the Threads.

Let’s first discuss about Memory Barrier which are the base for our further discussions. There are two type of memory barrier instructions in JMM – read barriers and write barrier.

A read barrier invalidates the local memory (cache, registers, etc) and then reads the contents from the main memory, so that changes made by other threads becomes visible to the current Thread.
A write barrier flushes out the contents of the processor’s local memory to the main memory, so that changes made by the current Thread becomes visible to the other threads.
JMM semantics for synchronized
When a thread acquires monitor of an object, by entering into a synchronized block of code, it performs a read barrier (invalidates the local memory and reads from the heap instead). Similarly exiting from a synchronized block as part of releasing the associated monitor, it performs a write barrier (flushes changes to the main memory)
Thus modifications to a shared state using synchronized block by one Thread, is guaranteed to be visible to subsequent synchronized reads by other threads. This guarantee is provided by JMM in presence of synchronized code block.

JMM semantics for Volatile fields
Read & write to volatile variables have same memory semantics as that of acquiring and releasing a monitor using synchronized code block. So the visibility of volatile field is guaranteed by the JMM. Moreover afterwards Java 1.5, volatile reads and writes are not reorderable with any other memory operations (volatile and non-volatile both). Thus when Thread A writes to a volatile variable V, and afterwards Thread B reads from variable V, any variable values that were visible to A at the time V was written are guaranteed now to be visible to B.

Let’s try to understand the same using the following code

Data data = null;
volatile boolean flag = false;

Thread A
————-
data = new Data();
flag = true; <-- writing to volatile will flush data as well as flag to main memory Thread B ------------- if(flag==true){ <-- as="" barrier="" data.="" flag="" font="" for="" from="" perform="" read="" reading="" volatile="" well="" will="">
use data;