Photo by Jacek Dylag on Unsplash


What are reference types?

Photo by Jonas Jacobsson on Unsplash


What is polymorphism?

Photo by Jonathon Young on Unsplash


  1. public: can be accessed from anywhere

2. protected: can be accessed from within the class itself, the package and by subclasses

3. package-private (default): can be accessed within the class itself and the package only

4. private: can be accessed only within the class

Public access

Read this to ace every interview question regarding interfaces.

Photo by Killian Cartignies on Unsplash

What are interfaces?

An interface is a reference type similar to a class but different in a sense that it can only contain abstract methods, default methods, static methods, (only default and static methods in interfaces can have a method body) nested types and constants. Interfaces cannot be instantiated; hence they do not have constructors. Instead, interfaces are implemented by classes (or extended by other interfaces).

What is a reference type?

Reference data types in Java are those which contain references to the address of dynamically created objects. …

Photo by Robert Katzki on Unsplash


Why use packages?

  • Better access control: Packages equip the developer with better access control.
  • Avoid name conflicts: Using packages prevents you from running into naming conflicts; for example, if you have a com.admin.User and a com.standard.User classes, you won’t run into a name conflict even though these two classes share the same name.
  • Better organization: If you’re working on a very large project, having an organized project structure is a must and…

Photo by Tracy Adams on Unsplash

In Java, a class can be derived from an existing class and when that happens, the derived class inherits the fields and the methods from that existing class. In Java, and many other languages, this is called inheritance. The class that is derived from an existing class is often referred to as the subclass or child class. The class that is being derived from is called the super class or the parent class.

Consider a simple inheritance digram below.

Photo by Nate Grant on Unsplash

Before we begin discussing the toString method, it is important to have a basic understanding of the class hierarchy in Java. All classes in Java inherit from the Object class; the Object class is at the root of the class hierarchy in Java.

Photo by Blake Connally on Unsplash

In Java, as is the case with most programming languages, strings are immutable; once a string is initialized with a value, it cannot be changed.


Take a look at the following code for instance:

Photo by Joshua Woroniecki on Unsplash

Static and final keywords in Java are at the core of the language and it is important to have an in-depth understanding of their function.

static variables

If you’ve every written a Java program of any scale, you’ve come across the “static” keyword. Your first program probably looked something like this:

Photo by antonio molinari on Unsplash

In this short article, I am going to introduce and implement the binary tree data structure. I will also answer questions such as “What is a full binary tree and what is a complete binary tree?”and “How do I traverse a binary tree?”.

First, let’s cover the basic definition of a tree. In computer science, data structures such a arrays, stacks, queues and linked lists are all linear data structures; they differ from trees, which have a hierarchical structure. A tree data structure is composed of nodes; each tree has a root node which has zero or more child nodes…

Anton Suprun

Computer Science Student, Programming Enthusiast

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store