What Are the Differences Between Interfaces and Abstract Classes in 2021?

What you are reading is the fifth in a series of articles titled "Stranger things in Java", inspired by the contents of my book "Java for Aliens". These articles are dedicated to insights into the Java language. Better understanding the topics we use every day will allow us to master Java coding in even the most difficult scenarios.

The definitions for abstract class and interface have evolved since version 8 of Java, and knowing how the two now differ and interact is crucial. An understanding of their key differences will help users best work with these tools to leverage their full potential. 

Some Helpful Extensions When Dealing With Types in .NET

If you are writing reusable code, chances are high that you will write quite some code that deals with types, generics, and interfaces. Over the years, the collection of my helper extensions for that have grown. As some of my upcoming posts use them, I share them (also) for future reference.

1. Check if a Type Is Deriving From Another Type

Deriving types is a common practice. To some extent, you can use pattern matching. Sometimes, that isn't enough, though (especially if you have a multi-level derivation path). This is when I use one of these two extensions:

The Interface of Java and the Many Faces of It

Before beginning the post of Interface of many faces, have you ever heard a phrase, “Man Of Many Faces”? if not, it means a person can be of everything or anything when it comes to portraying something. It can be one thing and a minute after another without losing its strength.

Java’s interface fits perfectly for this title. It is an integral part of java and has become so powerful over the years, that it shifted the way a Java programmer thinks. It has added various ways of doing things in Java. Depending on the number of methods only, an interface’s definition as well as the object creating process changes.

SKP’s Java/Java EE Gotchas: Revisiting Java SE 9 Features, Part 1

Preparing for an interview? Want to just revisit Java SE 9 features? Trying to recollect or revise Java SE programming constructs? Let me take you back in time to what was introduced first in Java SE 9? Join me for this tutorial series on Java as we all eagerly await the official release of Java SE 14!

As I promised, I am back with the code samples of my earlier article Java SE 9... What's New? You may refer the earlier article to understand the newly introduced features at a high level. This article provides the code samples for each of the features.

You may download the code samples for the following new features here. (Import as eclipse project, set compiler/environment as Java 9. Run the main class 'Java9Application' to see the output/outcome of the Code Samples.)

I plan to start by re-visiting a Java 8 feature, Default Interface Methods.

The Mystery of Traits in Scala

Crack the code — getting familiar with traits in Scala.

In this blog, we are getting familiar with traits in Scala and try to gather some knowledge on how to implement them in code. We will understand the trait in a better way by comparing it with Java language features like interfaces and abstract classes. 

Be More Functional: Java’s Functional Interfaces

Learn more about popular functional interfaces in Java, including Consumer, Function, and Predicate.

Hey tea lovers, this post is about the functional interfaces provided by Java. We will talk about the basic ones briefly. These functional interfaces are used by the Streams API heavily, so knowing them will make your life easier. Not just streams you can use it anywhere unless you want to. You can find the code on GitHub and the full project here.

Prerequisites

Just make sure you have a solid understanding of functional interfaces and lambdas. This post is dependent on these concepts.

OOP in Java: Polymorphism and Interfaces

As a senior member of my organization, I have to take interviews on regular basis as part of the recruitment process of our company. As an interviewer, I have witnessed some interesting observations about Java and the knowledge of individual interviewees. The experience ranges of the interviewees vary from around three to eight years.

In many cases, my observation is that the candidate knows the topic very well. Their theoretical knowledge is very good. And their answer quality shows that they have had hands-on work experience in different areas of core Java, like exception handling, the collections framework, generics, and objects. They have a more or less clear idea of what those things are. And in many cases, they are aware of new features added in more recent versions.

What’s in a Name: Java Naming Conventions

Imagine a world without names. What would happen if nothing in this world had a name? This article would have been a very different story. Oh sorry, we wouldn’t even be able to tell the story. What about if we had weird names? Then what will aliens think about us? So, basically, everything is in the name, especially when it comes to programming languages.

Programming is a story; every character and scene needs to have a name that properly tells you what it is and what it does. You should be careful while naming things: You don’t want to make your code hard to read or debug. Remember: You are the creator here. You can name anything from babies, stars, trees, and mountains, almost anything (almost). Paying little attention to this feature will make your code more readable, easy-to-debug, and whatnot. And you should be able to look at it after months and be able to understand it without any trouble.

Why Do We Need an Interface in OOP?

Most of us feel confused about the usefulness of interfaces at a first glance. We have questions like “Why do we need interfaces?" and “What is the advantage of using interfaces?" In this blog, we will try to find the answers to these questions.

Let’s begin with a simple example. Assume that you are a student and need to prepare for an exam. You know that there will be distractions during your exam preparation. We will use mobile applications and friends as our example. Let’s describe each as a class: