Menus

Dec 24, 2018

Explain different ways of creating a thread.Which one would you prefer and why ?


Java defines two ways by which a thread can be created.

By implementing the Runnable interface.
By extending the Thread class.


#Implementing the Runnable Interface
class MyThread implements Runnable
{
public void run()
{
System.out.println("concurrent thread started running..");
}
}

What is dependency injection?


IoC is all about inverting the control. To explain in layman's term, suppose you drive a car to your work place, it means you control the car. IoC principle suggests to invert the control, meaning instead of driving the car yourself, you hire a cab where another person will drive the car. Thus it is called inversion of the control from you to the cab driver. You don't have to drive a car yourself and let the driver do the driving so that you can focus on your main work.

IoC principle helps in designing loosely coupled classes which make them testable, maintainable and extensible.

The Inversion of Control (IoC) and Dependency Injection (DI) patterns are all about removing dependencies from your code.

Contact Form

Name

Email *

Message *