Can Abstract Class have a Constructor in Java?

Yes. Abstract classes can also have constructors just like any other normal class. The advantage of declaring a constructor within an abstract class is that it can be called from any subclass constructor using the super keyword to reuse the initialization logic when the subclass is being instantiated. This way you can put common instantiation … Read more

Why the main method is public static void in Java?

If you have started learning Java and wondering why we have to type public static void for the main method, we’ve got you covered. In this post, we will discuss the significance of using public static void in front of the main method. In the main method, we use public static void because the JVM … Read more

Is Constructor Overriding Runtime Polymorphism in Java?

No, constructor overriding is not possible in Java, so whether it is runtime polymorphism or not is out of question. If you override a method of parent class in subclass and try to call that method using parent class reference variable, JVM decides which method to call at runtime. However, each class will have their … Read more

Instance Variable vs Reference Variable in Java

In this post we’ll discuss the differences between Instance Variable and Reference Variable in Java, understand them with an example. In a nutshell, a reference variable is any variable that can hold reference of an object and an instance variable is a primitive or non-primitive variable that is declared within a class. Instance Variable Reference … Read more

C Program to Find Max and Min in 3D Array

In this example, we’ll write a C program to find maximum and minimum elements in a 3D array. Initially we’ve defined a 3 dimensional array with values We’ve also initialized the min and max variables with the first value the array We also declare 2 temporary variables to iterate over the array We use nested … Read more