Showing posts with label java investment bank. Show all posts
Showing posts with label java investment bank. Show all posts

Friday 30 August 2013

Top Most java interview with Investment bank -4


This is another set of investment bank java interview questions. This interview was not attended by me but I got this these questions from one of my team mate, who passed these interviews to receive the IB job offer. Here the main focus area were again java collections, memory model, java 1.5 concurrency and design pattern.
  Always remember your first impression is the most important and everybody know what is the first question in all interviews. It is 'tell me about yourself' or' tell me about current project'. Be well prepared for this questions which sets the tone for rest of your interview. If you are taking telephonic interview be very clear that your voice should be clear and there should not be any background noise.

1) Tell me about career profile and describe your one of the main project?
   then deep drive into the current project.
  • Why u are using these technology like JMS, Concurrency, Spring in your application?
  •  What feathers of java 1.6 you are using in your current application?
  •  How you r managing concurrency in application? 
  •  How the exceptions are handled in your application?

2) Java collections - When to use ArrayList and Linked list?
Java Collection


3) Application wants to load static data with limited memory foot print and it should be refreshed after regular interval. Implement LRU Cache ?
LRU Cache Implementation

4) What is soft reference, weak reference, phantom reference?
weak reference, simply put, is a reference that isn't strong enough to force an object to remain in memory. Weak references allow you to leverage the garbage collector's ability to determine reachability for you, so you don't have to do it yourself. It is used in java.util.WeakHashMap.
soft reference is exactly like a weak reference, except that it is less eager to throw away the object to which it refers. An object which is only weakly reachable (the strongest references to it areWeakReferences) will be discarded at the next garbage collection cycle, but an object which is softly reachable will generally stick around for a while.
phantom reference is quite different than either SoftReference or WeakReference. The object is marked for Garbage collection but it is finalised and have not yet reclaimed. The object is called as phantom reachable.  Its grip on its object is so tenuous that you can't even retrieve the object -- its get() method always returns null. The only use for such a reference is keeping track of when it gets enqueued into a ReferenceQueue, as at that point you know the object to which it pointed is dead.

5) How is memory management in java? how the heap is divided in different area?
Java Memory Mgmt

6) Where String literals are stored in heap?
Java Memory Mgmt

7) How to handle out of memory error and what tools we can use to figure out memory leaks?

8) What is Synchronization and locks in java 1.5?
Java 1.5 features

9) Explain new feathers in java 1.5 and java 1.6?
Java 1.5 features

There are a few new features in Java 1.6, but not many:
  • @Override annotations on methods specified by an interface
  • NavigableSetNavigableSetDeque
Those are the changes that I can think of.
Wait, there's more:
  • Pluggable Annotation Processing
  • Programmatically access to the compiler through ToolProvider 


10) How to do thread scheduling in java 1.5?
Java Concurrency

11) What are new concurrency classes in java 1.5?
Java Concurrency

12) Explain Singleton design pattern and what is double check locking (DCL)  and how to make singleton classes using volatile?
Design Pattern [Singleton]


13) What is the difference between correlated subqueries and uncorrelated subqueries?
Uncorrelated subquery is that the subquery can be run independently of the outer query. Basically, the subquery has no relationship with the outer query.
example :
select * from employee where id in (select employee_id from department where dept_id=10);
  Here sub query \ inner query is not dependent on outer query.
Correlated subquery has the opposite property – the subquery cannot be run independently of the outer query. 
SELECT *FROM Employee Emp1
WHERE (1) = (
SELECT COUNT(DISTINCT(Emp2.Salary))
FROM Employee Emp2
WHERE Emp2.Salary > Emp1.Salary)
What you will notice in the correlated subquery above is that the inner subquery uses Emp1.Salary, but the alias Emp1 is created in the outer query. This is why it is called a correlated subquery, because the subquery references a value in it’s WHERE clause (in this case, it uses a column belonging to Emp1) that is used in the outer query. 

14) If Parent class is Serializable, then Child class should be Serializable classs ?
yes, a subclass IS-A superclass, and hence child will also be IS-A Serializable too.
However, if the question is referring to an object actually being serializable, then maybe not, as it is possible for a subclass to provide readObject() and writeObject() methods, that thows a NotSerializableException.


Puzzle :
1) You are in one room at 5'th floor of building and it has 3 bulbs and the switch for these bulbs are in ground floor and you can go down only 1 time and Tell me how you know particular switch for each bulb? ,, tip --use bulb heating**
2) You have 1000 teams and each team plays knock out with each other, how many minimum matches we need to schedule to figure out winner?
3) Write the programme to get square root of 100? do not use java math Square root functions?

Management Round:
1) Tell me about yourself?
2) Why you want to leave current job?
3) Why you want to join this bank? ..[Get the history of bank and current CEO details and latest mergers]
4) Your key strengths and weakness?
5) Tell me how you were managing team?

HR Round:
1) Why would you like to leave current role?
2) What is your long term plan, how you would you like to growth your career?
[Answer of these Mgmt/HR Questions are listed here]Overall process took around 1.5 months from first round to final job offer. one more point there was onsite puzzle solving in first round using eclipse and we need to make Junit test cases to demonstrate the understanding of Test driven development.

More interview questions from investment bank job interviews

Important topic to prepare for Java interview:
1) JAVA 1.5 details

Banking development work requires analytical skills so you can be surprised by puzzles. Sample puzzles at listed in blog Frequently asked java puzzles

Top Most Java Memory Management

We are covering here -'Java garbage collection interview questions' or 'Java memory interview questions' in details. The topic is always asked to senior java developers to verify the java memory model understanding. In bigger project taking care of VM memory becomes very important due to more memory required at peak time processing in application.  

In this topic frequently asked questions are:

  • What is Garbage collection?
  • How to do analysis of java memory issues?
  • Explain Java memory model?
  • What are garbage collectors?
  • How to use java profilers?
  • Have you worked in application performance improvement?
  • What are the memory issues you have faced in your application?

Garbage Collection:


Garbage collection (GC) is a form of automatic memory management. The garbage collector, or just collector, attempts to reclaim garbage, or memory occupied by objects that are no longer in use by the program. Garbage collection was invented by John McCarthy around 1959 to solve problems in Lisp.

Garbage collection is often portrayed as the opposite of manual memory management, which requires the programmer to specify which objects to deallocate and return to the memory system. However, many systems use a combination of approaches, including other techniques such as stack allocation and region inference.

Resources other than memory, such as network sockets, database handles, user interaction windows, and file and device descriptors, are not typically handled by garbage collection. Methods used to manage such resources, particularly destructors, may suffice to manage memory as well, leaving no need for GC. Some GC systems allow such other resources to be associated with a region of memory that, when collected, causes the other resource to be reclaimed; this is called finalization. Finalization may introduce complications limiting its usability, such as intolerable latency between disuse and reclaim of especially limited resources, or a lack of control over which thread performs the work of reclaiming.

Memory is divided in mainly 3 areas:
  •  Young\Eden Generation : for newly created objects.
  •  Tenured Generation : for old objects which are survived after minor gc.
  •  Perm Space : for class definition, meta data and string pools.



At initialization, a maximum address space is virtually reserved but not allocated to physical memory unless it is needed. The complete address space reserved for object memory can be divided into the young and tenured generations.The young generation consists of eden and two survivor spaces. Most objects are initially allocated in eden. One survivor space is empty at any time, and serves as the destination of any live objects in eden and the other survivor space during the next copying collection. Objects are copied between survivor spaces in this way until they are old enough to be tenured (copied to the tenured generation). A third generation closely related to the tenured generation is the permanent generation which holds data needed by the virtual machine to describe objects that do not have an equivalence at the Java language level.

Java objects are created in Heap and Heap is divided into three parts or generations of garbage collection in Java as mentioned above. New Generation is divided into three parts known as 
  •   Eden space
  •   Survivor 1 
  •   Survivor 2 space. 
When an object first created in heap its gets created in new generation inside Eden space and after subsequent Minor Garbage collection if object survives its gets moved to survivor 1 and then Survivor 2 before Major Garbage collection moved that object to Old or tenured generation.

Permanent generation of Heap or Perm Area of Heap is special and it is used to stores String pool,  Meta data related to classes and method in JVM.

Out Of Memory / OOM :
   If it happens in your application take it is opportunity to display your technical skills. In technical term it means the JVM does not have space to put objects in tenured space which are survived in minor collection and it stops working or responding due to no memory to do further processing.
 
These are terms used in context of java memory management:

  • Throughput is the percentage of total time not spent in garbage collection, considered over long periods of time. Throughput includes time spent in allocation (but tuning for speed of allocation is generally not needed).
  • Pauses are the times when an application appears unresponsive because garbage collection is occurring.
  • Footprint is the working set of a process, measured in pages and cache lines. On systems with limited physical memory or many processes, footprint may dictate scalability. 
  • Promptness is the time between when an object becomes dead and when the memory becomes available, an important consideration for distributed systems, including remote method invocation (RMI).
  • Heap Dump is a list of objects in the memory of JVM as well as the content of the memory occupied by those objects. It preserves the value of any attributes of the objects, including references to other objects. In other words, a heap dump gives you a complete picture of the memory.There are multiple tools that allow you to dump heap in a Java process:Some tools like VisualVM and memory profilers allow you to initiate a heap dump from the GUI, but you don’t need any fancy tools here—jmap will do just fine. As it provides the most general case, we'll use jmap in the next example.Before you dump heap, be sure to keep the following issues in mind:Note that the -F option, which will dump non-responsive programs, might be useful on UNIX systems, but is not available on Windows. Note also that JDK 6 includes the option +XX:+HeapDumpOnOutOfMemoryError that will dump heap whenever the OutOfMemoryError alert is encountered. This can be a useful option, but keep in mind that it has the potential to consume significant amounts of disk space.


The basic principles of garbage collection are:

  1. Find data objects in a program that cannot be accessed in the future
  2. Reclaim the resources used by those objects



   An object is considered garbage when it can no longer be reached from any pointer in the running program. The most straightforward garbage collection algorithms simply iterate over every reachable object. Any objects left over are then considered garbage. The time this approach takes is proportional to the number of live objects, which is prohibitive for large applications maintaining lots of live data.The blue area in the diagram below is a typical distribution for the lifetimes of objects. The X axis is object lifetimes measured in bytes allocated. The byte count on the Y axis is the total bytes in objects with the corresponding lifetime. The sharp peak at the left represents objects that can be reclaimed (i.e., have "died") shortly after being allocated. Iterator objects, for example, are often alive for the duration of a single loop.   


Application GC bytes allocation is shown in above picture. Majority of byte survival happens in Minor Collection and majority of objects are cleared in Major collections. Some objects do live longer, and so the distribution stretches out to the the right. For instance, there are typically some objects allocated at initialisation that live until the process exits. Between these two extremes are objects that live for the duration of some intermediate computation, seen here as the lump to the right of the initial peak. Some applications have very different looking distributions, but a surprisingly large number possess this general shape. Efficient collection is made possible by focusing on the fact that a majority of objects "die young".



Collectors

The Java HotSpot VM includes three different collectors, each with different performance characteristics.
  • The serial collector uses a single thread to perform all garbage collection work, which makes it relatively efficient since there is no communication overhead between threads. It is best-suited to single processor machines, since it cannot take advantage of multiprocessor hardware, although it can be useful on multiprocessors for applications with small data sets (up to approximately 100MB). The serial collector is selected by default on certain hardware and operating system configurations, or can be explicitly enabled with the option -XX:+UseSerialGC.
  • The parallel collector (also known as the throughput collector) performs minor collections in parallel, which can significantly reduce garbage collection overhead. It is intended for applications with medium- to large-sized data sets that are run on multiprocessor or multi-threaded hardware. The parallel collector is selected by default on certain hardware and operating system configurations, or can be explicitly enabled with the option -XX:+UseParallelGC.
  • Newparallel compaction is a feature introduced in J2SE 5.0 update 6 and enhanced in Java SE 6 that allows the parallel collector to perform major collections in parallel. Without parallel compaction, major collections are performed using a single thread, which can significantly limit scalability. Parallel compaction is enabled by adding the option -XX:+UseParallelOldGC to the command line.
  • The concurrent collector performs most of its work concurrently (i.e., while the application is still running) to keep garbage collection pauses short. It is designed for applications with medium- to large-sized data sets for which response time is more important than overall throughput, since the techniques used to minimize pauses can reduce application performance. The concurrent collector is enabled with the option -XX:+UseConcMarkSweepGC.

    VM Options for GC details:

    • -verbose:gc — prints basic information about GC to the standard output
    • -XX:+PrintGCTimeStamps — prints the times that GC executes
    • -XX:+PrintGCDetails — prints statistics about different regions of memory in the JVM
    • -Xloggc: — logs the results of GC in the given file.


      These Command line options are available via JMX to monitor VM memory-
      • -Dcom.sun.management.jmxremote — enables JMX monitoring
      • -Dcom.sun.management.jmxremote.port = — controls the port for JMX monitoring
      • com.sun.management.jmxremote.ssl
      • com.sun.management.jmxremote.authenticate
      • If you're using JDK 6, you can use tool called jmap on any platform.

        What is Garbage First Collector?

         Recently in one java interview, I was asked about Garbage First collector and Garbage First collector splits the heap up into fixed-size regions and tracks the live data in those regions. It keeps a set of pointers — the "remembered set" — into and out of the region. When a GC is deemed necessary, it collects the regions with less live data first (hence, "garbage first"). Often, this can mean collecting an entire region in one step: if the number of pointers into a region is zero, then it doesn't need to do a mark or sweep of that region.
            For each region, it tracks various metrics that describe how long it will take to collect them. You can give it a soft real-time constraint about pause times, and it then tries to collect as much garbage as it can in that constrained time.

        Technical description

        The G1 collector achieves high performance and pause time goals through several techniques.
        The heap is partitioned into a set of equal-sized heap regions, each a contiguous range of virtual memory. G1 performs a concurrent global marking phase to determine the liveness of objects throughout the heap. After the mark phase completes, G1 knows which regions are mostly empty. It collects in these regions first, which usually yields a large amount of free space. This is why this method of garbage collection is called Garbage-First. As the name suggests, G1 concentrates its collection and compaction activity on the areas of the heap that are likely to be full of reclaimable objects, that is, garbage. G1 uses a pause prediction model to meet a user-defined pause time target and selects the number of regions to collect based on the specified pause time target.
        The regions identified by G1 as ripe for reclamation are garbage collected using evacuation. G1 copies objects from one or more regions of the heap to a single region on the heap, and in the process both compacts and frees up memory. This evacuation is performed in parallel on multi-processors, to decrease pause times and increase throughput. Thus, with each garbage collection, G1 continuously works to reduce fragmentation, working within the user defined pause times. This is beyond the capability of both the previous methods. CMS (Concurrent Mark Sweep ) garbage collection does not do compaction. ParallelOld garbage collection performs only whole-heap compaction, which results in considerable pause times.
        It is important to note that G1 is not a real-time collector. It meets the set pause time target with high probability but not absolute certainty. Based on data from previous collections, G1 does an estimate of how many regions can be collected within the user specified target time. Thus, the collector has a reasonably accurate model of the cost of collecting the regions, and it uses this model to determine which and how many regions to collect while staying within the pause time target.

        Recommended Use Cases for G1

        The first focus of G1 is to provide a solution for users running applications that require large heaps with limited GC latency. This means heap sizes of around 6GB or larger, and stable and predictable pause time below 0.5 seconds.
        Applications running today with either the CMS or the ParallelOld garbage collector would benefit switching to G1 if the application has one or more of the following traits.
        • More than 50% of the Java heap is occupied with live data.
        • The rate of object allocation rate or promotion varies significantly.
        • Undesired long garbage collection or compaction pauses (longer than 0.5 to 1 second)

          Thursday 29 August 2013

          Top Most Java 1.7 features



          'Java latest changes' or' 'Java 1.7 changes' are covered in this topic. Java 1.7 [ Dolphin] is major update after java 1.5 tiger release. It is done on 2011-07-28 after around 5 years of java release 1.6 [Mustang]. These are major changes in java 1.7 release and most important is definitely 'Auto closeable' of resources.

          1) Autocloseable Try Statement defining Resources – Java 1.7 introduces all new try-with-resources statement using which declaration and initialization of one or more resources can happen. But only the resources that implement the interface “java.lang.AutoCloseable” can be declared. Example:
                try (BufferedReader bufferedReader = new BufferedReader( FileReader(path)))
                   {             return bufferedReader.readLine();  
                   }
            In this code snippet, sampleBufferedReader instance is created within the try statement. Note that the example does not include a finally block that contains a code to close sampleBufferedReader as in Java 1.6 or earlier versions. Java 1.7 automatically closes the resources that are instantiated within the try-with-resources statement as shown above.

          2) Catch Block Handling Multiple Exceptions – In Java 1.5 and Java 1.6, a catch block can handle only one type of exception. But in Java 1.7 and later versions, a single catch block can handle multiple exceptions. Here is an example showing catch blocks in Java 1.6:
               try {    }
                catch(SQLException exp1)
                {     throw exp1;    }
                 catch(IOException exp2)
                 {    throw exp2;   }
          The same code snippet can be modified in Java 1.7 as:
                try  {….      }
                catch(SQLException | IOException |ArrayIndexOutofBoundsException exp1)
                {     throw exp1;   }

          3) String Object as Expression in Switch Statement – So far only integral types are used as expressions in switch statement. But Java 1.7 permits usage of String object as a valid expression. Example:
             example:           
                                      case "CASE1":
                                               System.out.println(“CASE1”);
                                               break;

          4) JDBC in Java 1.7
          JDBC contained in Java 1.7 / Java SE 7 is JDBC 4.1 that is newly getting introduced. JDBC 4.1 is more efficient when compared to JDBC 4.0.

          5) Language Enhancements in JDBC 1.7
          Java 1.7 introduces many language enhancements:

            Integral Types as Binary Literals – In Java 1.7 / Java SE 7, the integral types namely byte, short, int and long can also be expressed with the binary number system. To specify these integral types as binary literals, add the prefix 0B or 0b to number. For example, here is a byte literal represented as 8-bit binary number:
               byte sampleByte = (byte)0b01001101;
             
            Underscores Between Digits in Numeric Literal – In Java 1.7 and all later versions, “_” can be used in-between digits in any numeric literal. “_” can be used to group the digits similar to what “,” does when a bigger number is specified. But “_” can be specified only between digits and not in the beginning or end of the number. Example:
          long NUMBER = 444_67_3459L;
          In this example, the switch expression contains a string called sampleString.  The value of this string is matched with every case label and when the string content matches with case label then the corresponding case gets executed. 

            Automatic Type Inference during the Generic Instance Creation – In Java 1.7 while creating a generic instance, empty parameters namely <> can be specified instead of specifying the exact type arguments. However, this is permitted only in cases where the compiler can infer the appropriate type arguments. For example, in Java 1.7 you can specify:
                sampleMap = new HashMap<>();
          Thus HashMap<> can be specified instead of HashMap>;. This <>; empty parameters of Java 1.7 are named as diamond operator.

          6) Suppress Warnings - When declaring varargs method that includes parameterized types, if the body of the varargs method does not throw any exceptions like ClassCastException (which occurs due to improper handling of the varargs formal parameter) then the warnings can be suppressed in Java 1.7 by three different ways: 
          (1) Add annotation @SafeVarargs to static method declarations and non constructor method declarations 
          (2) Add annotation @SuppressWarnings({"unchecked", "varargs"}) to varargs method declaration 
          (3) Directly use compiler option “-Xlint:varargs.
          By suppressing the warnings in varargs method, occurrence of unchecked warnings can be prevented at compile time thus preventing Heap Pollution.

          7) Java Virtual Machine Enhancements in Java 1.7
          Java SE 7 / Java 1.7 newly introduce a JVM instruction called “invokedynamic” instruction.  Using “invokedynamic” instruction, the dynamic types programming language implementation becomes simpler. Thus Java 1.7 enables JVM support for the non-java languages.  


          Top Most java interview with Investment bank - 5


          Getting a new job looks very tedious work and it needs the preparation. better you are prepared important topics and you have more chances of winning the interview. It is not just chance, its your hard work which makes way for you. After long time, again I started giving interviews for my next move. This time I am looking for more senior role similar to technical manager but still I need to clear java technical round and here are those questions:





          **Wining Attitude is the Key for interviews**




          Questions :-

          1) Your Current project and Role\ Responsibilities?

          2) Explain your current application and it's design?

          3) Explain JMS Transaction and how you can control transaction from you receive the message to persisting data into DB?

          4) How to handle DB transaction in Spring?

          5) What is benefits of Spring?

          6) HashMap VS TreeMap which one to use, how to decide?

          7) How to create immutable Objects?

          8) What is annotation and what is benefits?

          9) How JIXB xml parsing works?

          10) Threading, what happens if same object instance is read by two threads?

          11) If one reader thread and one writer thread act on one objects double variable and writer thread is trying to update the value from 4 to 5. if both does this call at same time what value reader thread will see for double variable?  [ Hint double writing is not atomic in java]

          12) If you have java application cache where  you have 1000 reads  but very less writes into cache, which locking you will you and how? tell me the class name?

          Suddenly interview moved to web application technology side and they asked these questions:

          1) What is application context in web app?

          2) What dispatcher servlet do in Spring mvc?


          Two design discussion

          1) Large file having text and how we can find the word count in the file and which collection to use?

          2) We have Professor , Course and Student table and one professor can take multiple course and one student can take multiple courses. How to find out which professor is having maximum students write query and table design?

          Best of luck for any upcoming interviews. Important topic to cover for interview -

          1) JAVA 1.5 details
          2) Java Collection Interview questions
          3) XML PArsing
          4) JDBC Interview Questions
          5) Hibernate interview questions
          6) Java Threading questions
          7) Java Concurrency questions.
          8) JMS interview questions.
          9) Spring Framework


          Friday 23 August 2013

          Top Most java interview with Investment bank -3

          This Interview was scheduled on Aug,2011 with one of the BIG 4 US banks. The positions was related to senior java developer and they were looking for strong java candidate with problem solving skills. They had a Rule based java application on which they were facing performance issue. The application was using Hibernate,Spring, Java 1.5 and JMS with Oracle database.

          1'st Round ) It was Quick fire round with 20  minutes telephonic interviews.
          Technical questions:
          1. Benefits of using Hibernate in application? 
          2. How to manage transaction in Hibernate and what all are transaction attributes?
          3. How to avoid phantom read using in Database operations?
          4. What is Queue and Topic and How to manage transaction in JMS?
          5. What is garbage collection?
          6. What need to be taken care on Java performance?
          7. How to do application profiling?
          8. What is database index and what is cluster index?
          9. Difference in Database functions\procedure and trigger?
          2) Second Round tech. interview
          It was second round face to face technical interview and it was totally focused on hibernate. I was not sure why interviewee is just asking questions on Hibernate.
          1. What is cascade all in hibernate setting?
          2. how to maintain same object in two hibernate sessions?
          3. what is Session.merge()?
          4. what is datasource and what is benefits?
          5. what is transaction management?
          6. what is DurableSubscriber?
          7. How to avoid circular dependency?
          8. How to do transaction management ? 
          9. How hashmap get and set works?
          10. How to design the big application where lots of request comes a same time and your application should able to handle all requests? why we should use JMS and what are the other alternative?
          11. diff in runnable and callable?
          12. diff in ArrayBlockingQueue, ConcurrentLinkedQueue?
          13. How the ExecutorService works?
          14. Have you used concurrent hashmap?
          15. How the task are submitted in executor framework?
          16. Java 1.5 concurrency package benefit?
          17.  what is Drul rule engine ?

             My second round went well , except deep questions in hibernate . I was able to give answers but they were not satisfied with my answers on hibernate as last time I worked in hibernate was 2 years before and finally got rejected here.

          Wednesday 21 August 2013

          Top Most Top 10 Tips for face to face technical Interview


          These are top 10 things we need to take care during face to face technical interview. Very few people are master in this and with these basic skills they clear the technical interviews very easily. First thing we need to understand that the interviewer are most of time are not prepared for very specific questions so they look for basic things, which can be your confidence, your dressing or your attitude in interview. These soft skills can be improved with practice.

          1) Practice Good Nonverbal Communication
                  It's about demonstrating confidence: standing straight, making eye contact and connecting with a good, firm handshake. That first impression can be a great beginning -- or quick ending -- to your interview.

           2) Dress for the Job or Company
               Today's casual dress codes do not give you permission to dress as "they" do when you interview. It is important to look professional and well-groomed. Whether you wear a suit or something less formal depends on the company culture and the position you are seeking. If possible, call to find out about the company dress code before the interview.

          3) Listen
              From the very beginning of the interview, your interviewer is giving you information, either directly or indirectly. If you are not hearing it, you are missing a major opportunity. Good communication skills include listening and letting the person know you heard what he said. Observe your interviewer, and match that style and pace.

          4) Don't Talk Too Much
               Telling the interviewer more than he needs to know could be a fatal mistake. When you have not prepared ahead of time, you may tend to ramble, sometimes talking yourself right out of the job. Prepare for the interview by reading through the job posting, matching your skills with the position's requirements and relating only that information.

           5) Don't Be Too Familiar
                The interview is a professional meeting to talk business. This is not about making a new friend. Your level of familiarity should mimic the interviewer's demeanour. It is important to bring energy and enthusiasm to the interview and to ask questions, but do not overstep your place as a candidate looking for a job.

          6) Use Appropriate Technical Language
              It's a given that you should use technical language during the interview. Be aware of any inappropriate slang words or references to age, race, religion, politics or sexual orientation -- these topics could send you out the door very quickly.

           7) Show Attitude 
              Attitude plays a key role in your interview success. There is a fine balance between confidence, professionalism and modesty. Even if you're putting on a performance to demonstrate your ability, overconfidence is as bad, if not worse, as being too reserved.

           8)Take Care to Answer the Questions
              When an interviewer asks for an example of a time when you did something, he is seeking a sample of your past behaviour. If you fail to relate a specific example, you not only don't answer the question, but you also miss an opportunity to prove your ability and talk about your skills.

           9) Ask Questions
          When asked if they have any questions, most candidates answer, "No." Wrong answer. It is extremely important to ask questions to demonstrate an interest in what goes on in the company. Asking questions also gives you the opportunity to find out if this is the right place for you. The best questions come from listening to what is asked during the interview and asking for additional information.

           10) Don't show Desperation
          When you interview with the "please, please hire me" approach, you appear desperate and less confident. Maintain the three C's during the interview: cool, calm and confident. You know you can do the job; make sure the interviewer believes you can, too.

          General Questions  
          1. Tell us about yourself?
          Keep your answer very simple and brief. Don't prolong by telling your family history and schooling. Be brief and focus more on your skills initiatives and adaptability.

          2. Why should we hire you?
          Because I have all the attributes that this role requires. Knowledge, experience, skills and abilities. You need to be confident while replying and no vague answers.

          3. Why are you looking for a change? or Why do you want to leave your company?
          Be positive while answering. You want to work with a company where you can make a long term career. Where you can use your skills and learn new skills. Be honest if there was any retrenchment in the previous company e.g. Our Department was consolidated or eliminated.

          4. What are your strengths?
          Your strengths should relate to the company and job opening. I have a proven track record as an achiever.Positive attitude, good sense of humour, good communication skills, dedicated, team player, willingness to walk the extramile to achieve excellence etc.   Your answer should highlight the qualities that will help you succeed in this particular job. (Back up each point with something specific). Give examples and quantify how your strengths benefited your previous employers. You should also demonstrate reliability, and the ability to stick with a difficult task yet change courses rapidly when required.

          5. What are your weaknesses?
          Never say you do not have any weak points. Try not to reveal your personal characteristics. I often get impatient with others sloppy work.
          The best “weaknesses” are disguised as strengths, such as “I dislike not being challenged at work”. Another good approach is to mention a weakness that is irrelevant for the job or one that can be overcome with training. Try to keep these to one weakness, explaining why you think it is a weakness and what you are doing to overcome the problem – a well thought out strategy you have developed to deal with the issue will turn this potentially tricky question into a positive.
          One common variation on this question is to ask about any problems or failures you’ve encountered in previous positions. In describing problems, pick ones you’ve solved and describe how you overcame it. Show yourself to be a good team player by crediting co-workers for all their contributions. To distance yourself from failure, pick one that occurred earlier in your career when you were still learning. Don’t blame others – simply explain how you analysed your mistake and learned from it.

          6. What challenges did you face in your previous jobs?

          Getting things planned and done on time within the budget. Quote any example that you have experienced.

          7. How will you motivate your team?
          Bottom line is do it show it and inspire. Involve all the members in the ongoing development and progress of the company. Communicate and interact with the team members. They want regular updates on their personal performance. Keep them updated.Celebrate individual and team performance. Catch people doing something right and focus on recognising excellent performance.Set challenging goals. Team will work hard to accomplish them. Believe in your people. Majority of them want to perform.Motivate employes for the next level. Consistent and transparent with the team. Let the members know why doing an assigned task is important to you the Organisation and them.Set the example for others to follow.

          8. “What’s the worst problem you’ve ever faced?”
          Here the interviewer is offering you the two ways to trip yourself up:
          • First of all, the question doesn’t confine itself to the workplace, so there is temptation to reveal a personal problem. Don’t! Restrict yourself to employment matters only.
          • Second, you are being asked to reveal a weakness or error again. You must have a good response ready for this question, one which shows how well you reacted when everything depended on it.
          Always show a problem you have solved and concentrate your answer on the solution not the problem.

          9. “How would you describe a typical day in your current job?”
          You are eager to look good but don’t make the common mistake of exaggerating your current position. Mentioning some of the routine tasks in your day adds realism to your description and show that you don’t neglect important details such as paperwork. Put yourself in the interviewer’s place as your answer. When you’ve been doing a job for years it becomes second nature to you, and you must be aware of all the tasks you undertake. You should spend a few days making notes of your activities at work to regain an outsider’s perspective. Try to show that you make good use of your time, that you plan before you begin your work and that you review your achievements at the end of it


          Java Technical Interview Topics:
          1) JAVA 1.5 details

          Reading :
            http://www.changeboard.com.sg/content/3823/jobseeker/interview-performance/typical-interview-questions-for-senior-professionals/

          Monday 19 August 2013

          Top Most Java Producer and Consumer Implementation using Blocking Queue

          'Java Consumer Producer' example - This is one of frequently asked questions to senior core java developer. Java concurrency producer and consumer solution is demonstrated below. 
          Java Concurrency Queuing options:
           The java concurrent executors and task holding queues can be configured in three ways-
          Direct handoffs :  A good default choice for a work queue is a SynchronousQueue that hands off tasks to threads without otherwise holding them. Here, an attempt to queue a task will fail if no threads are immediately available to run it, so a new thread will be constructed. This policy avoids lockups when handling sets of requests that might have internal dependencies. Direct handoffs generally require unbounded maximumPoolSizes to avoid rejection of new submitted tasks. This in turn admits the possibility of unbounded thread growth when commands continue to arrive on average faster than they can be processed.

          Unbounded queues : Using an unbounded queue (for example a LinkedBlockingQueue without a predefined capacity) will cause new tasks to wait in the queue when all corePoolSize threads are busy. Thus, no more than corePoolSize threads will ever be created. (And the value of the maximumPoolSize therefore doesn't have any effect.) This may be appropriate when each task is completely independent of others, so tasks cannot affect each others execution; for example, in a web page server. While this style of queuing can be useful in smoothing out transient bursts of requests, it admits the possibility of unbounded work queue growth when commands continue to arrive on average faster than they can be processed.

          Bounded queues : A bounded queue (for example, an ArrayBlockingQueue) helps prevent resource exhaustion when used with finite maximumPoolSizes, but can be more difficult to tune and control. Queue sizes and maximum pool sizes may be traded off for each other: Using large queues and small pools minimizes CPU usage, OS resources, and context-switching overhead, but can lead to artificially low throughput. If tasks frequently block (for example if they are I/O bound), a system may be able to schedule time for more threads than you otherwise allow. Use of small queues generally requires larger pool sizes, which keeps CPUs busier but may encounter unacceptable scheduling overhead, which also decreases throughput.

             Example of PriorityBlockingQueue and see how the comparable is used with priority of task which depends on implementation of compare method in task.
          From Java Docs-

          The Blocking queue here is bounded with 11 as initial capacity as default constructor.  The queue is based on priority and least priority data is processed 

          " An unbounded blocking queue that uses the same ordering rules as class PriorityQueue and supplies blocking retrieval operations. While this queue is logically unbounded, attempted additions may fail due to resource exhaustion (causing OutOfMemoryError). This class does not permit null elements. A priority queue relying on natural ordering also does not permit insertion of non-comparable objects (doing so results in ClassCastException).
          This class and its iterator implement all of the optional methods of the Collection and Iterator interfaces. The Iterator provided in method iterator() is not guaranteed to traverse the elements of the PriorityBlockingQueue in any particular order. If you need ordered traversal, consider using Arrays.sort(pq.toArray()). Also, methoddrainTo can be used to remove some or all elements in priority order and place them in another collection."




          Output
           Consumed Data [number=2, name=two]
           producer 0
           Consumed Data [number=10, name=ten]
           producer 1
           Consumed Data [number=20, name=twenty]
           producer 2
           Consumed Data [number=0, name=0]
           producer 3
           Consumed Data [number=1, name=1]
           producer 4
           Consumed Data [number=2, name=2]
           producer 5
           Consumed Data [number=3, name=3]


          Consumer Producer Solution with Synchronisation:
          This implementation with Synchronisation needs great care and it is more complicated in implementation:


          Output 
          The output will confim that there is no concurrency issue on putting data into same queue and wait() and notify() works perfectly fine.
           Got: 53613
           Put: 53614
           Got: 53614
           Put: 53615
           Got: 53615
           Put: 53616
           Got: 53616
           Put: 53617
           Got: 53617

          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