In Java programming, each object has a lock. A thread can acquire the lock for an object by using the synchronized keyword. The synchronized keyword can be applied in method level (coarse grained lock – can affect performance adversely) or block level of code (fine grained lock). Often using a lock on a method level is too coarse. Why lock up a pie...

Read More

The state chart diagram below describes the thread states.  ƒ  Runnable : Waiting for its turn to be picked for execution by the thread schedular based on thread priorities.   ƒ  Running: The processor is actively executing the thread code. It runs until it becomes blocked, or voluntarily gives up its turn with this static method Thread.yield(). Be...

Read More

Inversion of control (IOC) or Dependency Injection (DI) is a term used to resolve component dependencies by injecting an instantiated component to satisfy dependency as opposed to explicitly requesting a component. So components will not be explicitly requested but components are provided as needed with the help of an Inversion of controller contai...

Read More

Inversion of control (IOC) or Dependency Injection (DI) is a term used to resolve component dependencies by injecting an instantiated component to satisfy dependency as opposed to explicitly requesting a component. So components will not be explicitly requested but components are provided as needed with the help of an Inversion of controller contai...

Read More

Polymorphism – means the ability of a single variable of a given type to be used to reference objects of different types, and automatically call the method that is specific to the type of object the variable references. In a nutshell, polymorphism is a bottom-up method call. The benefit of polymorphism is that it is very easy to add new classes of ...

Read More

Method forName() is a static method of java.lang.Class. This can be used to dynamically load a class at run-time. Class.forName() loads the class if its not already loaded. It also executes the static block of loaded class. Then this method returns an instance of the loaded class. So a call to Class.forName(‘MyClass’) is going to do following Load ...

Read More

Callable interface was added in Java 5 to achieve some limitation in existing Runnable interface. A Thread created by implementing the Runnable interface cannot returns a result when the thread terminates. As the return type of run() method in Runnable interface is void. To overcome this the Callable interface was introduced in Java where we can re...

Read More

This is one of the most frequently asked interview Question for fresher or new developers. If you have a try/catch block with return inside it. Will the finally block be called? Consider the following scenario. // Condition 1 try { // some operations return success; } catch (Exception e) { throw e; } finally { ...

Read More

In design, you want the base class to present only an interface for its derived classes. This means, you don’t want anyone to actually instantiate an object of the base class. You only want to upcast to it (implicit upcasting, which gives you polymorphic behavior), so that its interface can be used. This is accomplished by making that class abstrac...

Read More

Java applications that uses I/O are excellent candidates for performance tuning. Profiling of Java applications handling significant volume of data will show significant time spent in I/O operations. This means substantial gains can be achieved by I/O performance tuning. Therefore, I/O efficiency should be a high priority for developers looking for...

Read More

FOLLOW US ON LinkedIn



Explore Tutu'rself