Top 10 OCAJP and OCPJP Exam Simulators for Java Certifications

There is no doubt that exam simulators play an important role in preparing for any Java certification e.g. OCAJP, OCPJP, OCEJWCD,   OCMJEA exams. In fact, they are one of the most important pillars because choosing a good exam simulator with a good book is generally the success mantra of many Java certification aspirants. The exam simulators prepare you well for exams by presenting the level of questions you can expect in real exams. They provide the much needed practice in exam like environment to gauge your speed and accuracy. I have personally seen the difference of 30% in score between people who do a lot of mock exams and who just goes without practicing mock exams. Candidates make more mistakes when they first took exams and by participating in mock tests, you train your mind to do fewer mistakes. They also help you to better handle the time pressure of real exam.

How to sort ArrayList in java - List Sorting - Ascending Descending Order

How to sort ArrayList ascending descending order
Sorting ArrayList in Java is not difficult, by using Collections.sort() method you can sort ArrayList in ascending and descending order in Java. Collections.sort() method optionally accept a Comparator and if provided it uses Comparator's compare method to compare Objects stored in Collection to compare with each other, in case of no explicit Comparator, Comparable interface's compareTo() method is used to compare objects from each other. If object's stored in ArrayList doesn't implements Comparable than they can not be sorted using Collections.sort() method in Java.

What is difference between wait and sleep in Java Thread?

Wait vs sleep in Java
Differences between wait and sleep method in Java multi-threading is one of the very old questions asked in Java interviews. Though both wait and sleep put thread on waiting state, they are completely different in terms of behavior and use cases. Thread.sleep(long millis) is meant for introducing pause, releasing CPU and giving another thread an opportunity to execute while wait is used for inter thread communication in Java. These methods are defined in java.lang.Object class and available to every object in Java. It is based upon object lock, if you remember every object in Java has implicit lock, also known as monitor. When a thread enter into a synchronized method it acquired the lock which is used to protect the critical reason e.g. it acquired lock on current object if it is going inside an instance synchronized method and lock object on class literal if its entering into a static synchronized method. By using wait() and notify() method two threads can communicate with each other which is key to solve many concurrency problems e.g. produce consumer problem, dining philosopher problem, reader and writer problem, and to implement several Concurrency designs.