Interfaces in Java – Explained in easy way!

In this post, I will talk about the real purpose of interfaces in Java.

When I was learning Java and Interfaces, all I know was that “An Interface does not have method behavior. You cannot create objects from an interface. Interface will extent another interface… blah blah”

Well, that’s what books will teach you. But, they don’t explain the real purpose of why Interface even came to existence. It’s only my experience in the industry that helped me uncover some of these mysteries..

Today, I will explain the real purpose of Interface that no book will teach you. I assure, after you read this article, you will have a clear picture on what are interfaces and their actual purpose. So, are you ready?

Let’s say that I want to write a code that will take a file path as an input and send that file to another computer/server. Don’t worry, I wont write annoying code. Just consider the case. So, Assume that there are two classes. ‘A’ and ‘B’. Class ‘A’ depends on Class ‘B’ and uses it’s methods to connect to server and send the file. So inside class ‘A’, you will have statements like these

B objB = new B();

Like the statements above, I use the B class everywhere in my project in thousands of lines. A question for you.. Do you see any problem with the above statement? Well, I see one problem. Let’s talk about it..

Let’s say that I found out that B is not sending the file in secure manner, and hence I want to switch to a new class ‘C’ which provides the same functionality as of ‘B’. Unfortunately, it’s not so easy to start using ‘C’ class as my code is tightly coupled with ‘B’. I mean, I need to replace the above statements and match it with methods available in ‘C’ class. If i were to make those changes in entire project, it will take days of effort.

What is the solution? How can I write my code in such way, that if i decided to use another class/library, it shouldn’t take much of an effort to switch? Well, the answer is “Interface”. let me explain..

Assume we have an interface ‘I’ with the following methods signatures..

Interface I{




Now, both the classes ‘B’ and ‘C’ implement that interface. By implementing, both ‘B’ and ‘C’ has to provide the behavior for these methods.

Inside my class ‘A’, I will have a statement like this..

I obj = new B();



Now, notice few things. The reference type of above object is an interface but the instance was of ‘B’s. Meaning that by using ‘obj’, I can only access the methods that are declared inside the interface ‘I’, but the behavior would be provided by ‘B’.

in future, if I did not like ‘B’ and want to switch to ‘C’, then all I have to do is change the statement from this

I obj = new B();


I obj = new C();

That way, all the rest of the code will remain same. I don’t need to change any additional lines of code. This will certainly save me a great deal of effort required to refactor my code.

So now, what is an Interface?

And interface is kind of like a contract or a standard that classes would follow. In fact, if you think about why an Interface named as ‘Interface’, it is basically to say that it is used as an ‘Interface’ through which, you will call a method behavior.

That’s why, you should always code for an interface, not for a class. I.e.. always try to have interfaces as reference type, so that in an event that you need to use a different implementation, there is no need of code refactoring.

Full Stack Developer Guide (Java)

java full stack developer guide

In this article we will understand the term “Full Stack Developer” and also explore why full stack developers are in great demand. If you are learning Java or related technologies, then this article will be of great help for your future. Hence, I recommend you to dedicate couple of minutes and read this article till the end.

Did you know?

An enterprise business application would comprise of stack of technologies. Everyone learns one or two Java technologies, but not many are skilled in complete stack of technologies.

Industry is in need for Full Stack Developers. They are rare and hence they are paid high.

Keep reading further..

Learning Java alone is not enough!

Many would think that if they learn Java, they can do miracles and start creating applications. Well, that’s no where close to reality. Java is the base for endless other technologies, that together will form an application. For example, if you are talking about a web application (Ex: A flight booking system, a banking system, or a school management application..) it will have the following layered architecture..

Full stack developer java
Full stack developer java

If you are not familiar with this architecture that’s fine! In layman terms, these are separation of various concerns. For example, the front end layer will have the technologies to create the user interface (Ex: HTML, JSP, CSS, JS etc). The Data Access layer will have technologies to talk to the database (Ex : Hibernate, JDBC..). Like wise, each layer will have its own set of technologies.

If you see, all these technologies run on Java platform and we use Java programming language to code our application using these technologies.

Although, you may not be able to create applications with just java, java will enable you to use these technologies to create applications!

Who is termed as a full stack developer?

A Full Stack Developer is an individual who has expertise in all these technologies, that fall in all the layers!

The individual will have the skills to create an end-to-end Java application or be able to fix issues in any layer.

Why do companies pay higher for a full stack developer?

Companies pay high for a full stack developer, in order to cut costs! Yes, you heard it right. Let me explain..

Imagine that you have a company and you are hiring people to create a Java application for you business. Which one of the following options, sounds good to you?

Option 1:

You will hire 4 individuals who specialize in each layer. For example, a front end developer who can only work on front end technologies. A Database Admin who can only work on databases,etc..

Assuming you would hire them for the salary of $100,000/-, You will have to pay $400,000/-

And what about the “other expenses” on these employees? You have to pay rent for their office cubicle, buy them a laptop, give them access to server, a desk phone, insurance,  extra allowances, bonus, appraisal, the list is simply quite long. Considering all these, the cost would only sky rocket!

Option 2:

You will hire couple of full stack developers, who are familiar with all the technologies in all the layers. Even if you pay the salary of $150,000/-, the total would come to $300,000/-

Considering the salary and “other expenses” you have to bear for each employee, your obvious answer is ‘Option 2’. And you are cutting the costs by a great deal!

Not only that, as full stack developer can resolve any issues that arise anywhere in the application. He don’t have to depend on anyone else. This is good for the company as the time it takes to resolve an issue is less and so is cost.

But, you may have a question as to why can’t a company still pay a lesser salary for a full stack developer? Well the answer is, “because they are rare!”. Diamond is expensive due to it’s rarity, same is applicable here too.

Why full stack developers are rare ?

Not everyone can be a full stack developer, because of the following challenges in their learning process..

  • Java is incredibly vast, and there are hundred’s of Java technologies. Individuals don’t know which technologies to learn and which one to ignore. Even worse, they may learn something that is no longer a popular choice in the industry.
  • Individuals don’t know the learning sequence. For example, you cannot learn Hibernate without having knowledge on the ‘Database’. All these technologies are dependent on each other and one need to follow a proper sequence.

For example, start from Core Java, and then J2EE, and then Database, and then Frameworks like Hibernate, Spring, etc… Apart from these, there are technologies that support the application development process (Ex : Maven, Ant, etc)

  • Full stack developer training’s are expensive.

Why are some people more productive / get better appraisal in office?

I have seen many IT professionals who just learn the basics of Java and then they jump in to contributing to real world projects. The problem is, they cannot make much of a progress, they loose the motive to work, they are the one who stay late night, yet they don’t do anything productive.

But, the core problem is that, their understanding of the technology is limited. Therefore, they go with “Trail and error” approach to fix a problem and there by wasting time.

Instead they need to focus on understanding the technology better and how things are working together. That is sure shot way to be more productive and hence better recognition inside office.

Why is it easy for a full stack developer to get a new job?

Java has the most number of Job openings than with any other technology. For the very reason there are many individuals who are learning Java. But here comes the problem..

Lets say that there are 100 Job openings and there are 4000 individuals who know Java. What are the chances of they getting hired? If we do a simple math, that comes downs to 1/40th. I.e.. out of 40 individuals who apply for a job, only 1 will get hired.

The problem is, every one is learning Java and think that its enough! Only few would realize the fact that companies prefer to take individual who know full stack of technologies. They even make the interview process easy for them. Because again, they are rare. I mean, going back to our previous example, lets say your company is hiring individual/freshers from college. Would you prefer to hire a person who know Java or the one who knows the entire stack of technologies?

Now lets do the math again. Out of 40 people, how many would have learnt full stack of technologies? Probably not more than 5!! So, now the chances of getting hired is 1/5th (or) you will have 8x chances of getting hired.

i.e.. if you apply for a job in 5 companies, you are almost guaranteed to get a job. And don’t forget that you are paid higher too.

Same is applicable even if you are planning to switch from an existing job.

Get better Job role

I have seen many individuals who wanted to get in to a new job role. Especially, the people with testing background, they wanted to get in to development role.

The problem is, ever company that you apply job to, will expect you to have knowledge on full stack of technologies.

So far, we have helped many individuals and we know exactly what it takes to get you, your desired job role.

You can get free trail access to the training Here