Monday 12 August 2013

Top Most Java Interviews Frequently Asked Puzzles

Interview puzzles is the best way to check person's analytical skills. In investment banking job you need analytical skill to perform day to day job. It is not only applicable to traders , but some level of analytical skills is required by people who are developing these systems for understand business. Now a days it is become common practice to ask 1-2 puzzles during investment bank interview to check the candidate's analytical skills. The best way to clear this round is practice common puzzles and understand the logic to solve them. 

1) Fibonacci in Java:
The input will be number n and the output should be sum for 0 to n. for example
for n =4 the result should be 0+1+2+3+4 = 10

2) String Reverse
The input String "abcde" should return "edcba".

3) Reversing a linked list in Java
Here is example of revering the linked list in java using recursive function:

4) Find the missing number in Java
You have an array of numbers from 1 to 100 (both inclusive). The size of the array is 100. The numbers are randomly added to the array, but there is one random empty slot in the array. What is the quickest way to find that slot as well as the number that should be put in the slot?
Try it for practice. please suggest the answer .
[Trick sum of n numbers is n*(n+1)/2]


5) Write a substring function in Java
String test= "AA BB CC BB BB CC BB";
String[]{"BB", "CC", "AA"}
Result shd be BB=4; CC=2 and AA=1
Since B occurred 4 times C did 2 times and A only 1 time.
This basic problem can be asked in different ways like, You have multiple words in new paper and find out the frequency of words in one page of news paper?

6) Reverse a String in Java
Reverse the String by java function without recursion and with recursion

7) Find one string inside another in Java
We can use String.indexOf( subString ) and it will return the first index of substring;
for Last Index : lastIndexOf(String str)

8) Algo for finding largest number in Array of Integer
Easy one, Check the integer one by one and find the largest number.

9) Java Runtime method invocation question:
Example : Tell the output of this
Answer is : 20 .

10) Suppose you have a large file with lots of words. How would you find the unique words and their count? What kind of data structure u will use? What will be the time complexity and space complexity?
We need to take care of two things counting the words and second duplicate. the best performance will be using hash function.


11) A train is one mile long. It travels at the rate of one mile a minute through a tunnel which is also one mile long. Can you say how long it will take for the train to pass completely through the tunnel? 

Answer : 2 minutes

it will take two minutes if you count the time for it to completely pass through the tunnel. One minute to pass through the tunnel and another one minute to drag itself out of the tunnel completely so two minutes nice question though well logical.



12) Convert String = "98989" into an integer without using any library functions in java.
Give fastest way to do it and explain why your method is best.
// converting string to number using ascii code


13) Write a program to shuffle a deck of 52 cards and shuffle them equally to 4 players.

Answer this puzzle by comments.
Given n stairs, how many number of ways can you climb if u use either 1 or 2 at a time?
for example you have 4 stairs and you can climb like
1,1,1,1
1,1,2
1,2,1
2,1,1
2,2
so in overall 5 ways for 3 stairs.

LinkWithin

Related Posts Plugin for WordPress, Blogger...

Labels

Core Java programming core java interview question Core Java Faq's Servlets coding database jsp-servlet spring Java linux unix interview questions java investment bank Web Services Interview investment bank mysql Senior java developer interviews best practices java collection tutorial RMI SQL Eclipse FIX protocol tutorial tibco J2EE groovy java questions SCJP grails java 5 tutorial jdbc beginner error and exception Design Patterns Java Programming Tutorials fundamentals general object oriented programming xml Java Programs Hibernate Examples Flex JAMon Java xml tutorial logging Jsp Struts 2.0 Sybase and SQL Server debugging java interviews performance FIX Protocol interview questions JUnit testing WebSphere date and time tutorial experienced java IO tutorial java concurrency thread Ejb Freshers Papers IT Management Java Exapmle Java Script SQL and database tutorial examples Scwcd ant tutorials concurrency example and tutorial future state homework java changes java threading tricky Agile Business of IT Development JSTL Java JSON tutorial Java multithreading Tutorials PM Scrum data structure and algorithm java puzzles java tips testing tips windows 8 5 way to create Singleton Object Architect Interview Questions and Answers Architecture Architecure Bluetooth server as swing application that searches bluetooth device in 10 meter circle and show all devices. You can send file to any bluetooth device. C Programming CIO Callable Statement in Java Circular dependency of Objects in Java Comparable Example in Collection Custom annotation in Java Developer Interview Divide and rule example in java Drupal Example of Singleton Pattern FIX protocol ForkJoin Example in Java 7 Get data from dynamic table with Java Script Git HTML and JavaScript Health Hello World TCP Client Server Networking Program Hibernate Basics Hibernate Interview Question Answer J2EE Interview Question And Answers J2ME GUI Program JEE Interview QA JMS interview question Java J2EE Hibernate Spring Struts Interview Question Java System Property Java Threads Manager Portlets Provident Fund Read data from any file in same location and give the required result. Reading Properties File in Java Redpoint Rest WebService Client Rest Webservice Test SAL join with ven diagram SCP UNIX COMMAND SSL Singleton Pattern in Java Spring Bean Initialization methods and their order Spring Interview Questions Struts Struts 2.0 Basics Struts 2.0 Design Pattern Submit Html Form With Java Script On The Fly Unix executable For Java Program XOM DOM SAX XP books computers core java; core java; object oriented programming data structure; java investment bank; design pattern dtd duplicate rows in table get browser name with jquery grails podcast inner class java beginners tutorial java cache java networking tutorial java spring java util; java collections; java questions java.java1.5 linked list mailto function with all browser oracle database oracle duplicate rows orm schema social spring mvc questions struts transaction tricks tweet windows xslt