Java Exception

During runtime (execution), our program sometimes encounter unforeseen errors. For example, our program may be in the middle of reading a file from disk when the disk crashed and we can no longer proceed to read the file. In unforeseen situations like this, the JVM would notify our program of the error by throwing an Exception object describing the error.

Java Abstract Class

In our previous article about polymorphism, we gave an example of a Shape class inherited by three subclasses, Rectangle, Triangle, and Circle. With polymorphism, a variable of type Shape can reference an object of any of the 3 subclasses.

Java Polymorphism

Previously, we said that inheritance is a feature of Java (and many object-oriented languages) that allows us to inherit variables and methods from another class. Inheritance denotes an “is a” relationship between classes. For example, if class Square inherits class Rectangle, then technically, an object of Square is an object of Rectangle because both classes have the same methods we can call.

Java Method Overriding

In the previous article, we covered class inheritance in Java, which is a feature to copy methods and member variables of another class into our class. We gave an example that since a square is a rectangle, the Square class can inherit the Rectangle class and get the area() for free.

Java Inheritance

In this article, we are going to cover one famous feature of Java, that is inheritance. If you ask someone, what is OOP? They will no doubt say something about inheritance and class hierarchy. Of course, this is just one feature of object-oriented concepts, but it’s an important one. We’re going to find out what it is!

Java Constructor and Initilization Method

In our earlier article Classes and Objects, we showed how to write a constructor for a simple class. In this article, we are going to dive deeper into the topic and show how constructors work and consider different types of constructors.

Java Method Overloading

Previously we covered the basics of writing classes and method in this article. Because object-oriented-programming (OOP) concepts are such an important topic in Java, we’re coming back to covering the rich OOP features offered by Java! In this article we are going to start slow and cover the simple topic of method overloading.

Java Operator Precedence

The following table is a list all operators and their precedence (order of evaluation). Operators with lower level are performed before higher level.

Java Loops

In the previous article, we covered if and switch statements that are used to selectively execute certain portion of our code based on certain conditions. In this article, we are going to cover another type of control construct called loops.

Java Branching Statements

In the previous article, we covered boolean expressions, which have a value of true or false, and logical operators that work on boolean values. This article covers how to use boolean expressions (or conditions) to decide what portion of our program to execute. For example, if a certain condition is true, our program should do this; otherwise is should do something else.