Special Programs

static vs non-static Java

Java novices are not much aware of static vs non-static or static to non-static calling. Let us find the rules through a program. In the following code, show() method is non-static and display() is static. The question is "Can we call a non-static method from static method?". Everyone says simply…

Public methods and Private Variables

What does it mean by Public methods and Private Variables? Declaring methods as public and variables as private is a programming technique and comes with its own advantages. We know private variables or methods cannot be accessed by composition (has-a relationship) by another class where as public members can be…

Java Overload Main Method

Java Overload Main Method Summary: It is a frequent asked interview question. Your answer is YES and is explained in simple terms in this tutorial "Java Overload Main Method". Method overloading is nothing but using the same method in the same class a number of times with different parameters. Just…

Can you make Private Constructor in Java?

Declaring a private constructor is a very rare usage. First of all can we do it? Yes, a constructor can be private and a private constructor can be overloaded also. Following program illustrates.

In the above program, Test class created two private constructors – default and overloaded with int…

Multiple Interfaces Implements Java

Summary: At the end of this tutorial, you will be comfortable with Multiple Interfaces Implements usage. Looks difficult at the beginning, but put some patience and start reading. Do some small programs to understand still better. This is required for a Developer. Any doubts may be forwarded to me. As…

Extend Multiple Classes Java

Extend Multiple Classes Java Summary: At the end of this tutorial you will understand the usage of Extend Multiple Classes Java in the code. We know earlier that Java does not support multiple inheritance but supports partially through interfaces. After extends there must be only one class of either concrete…

Can you make Static Constructor in Java?

Java does not permit to declare a constructor as static. Following are the reasons. 1. Static means for the same class. For example, static methods cannot be inherited. 2. With static, "this" reference (keyword) cannot be used. "this" is always linked to an object. A constructor always belongs to some…

public static void main(String args[])

public static void main is discussed in Simple terms for a very Beginner. In Java, the execution starts from main() method. But for compilation, main() is not required. Java's main() method syntax is quiet different from C/C++. Following is the public static void main complete signature public static void main(String…

Abstract class constructor and Interface abstract

These are two different concepts which can be explained easily by a novice having a little bit knowledge of abstract classes and interfaces. It is advised to read abstract classes before going through this topics. It gives thorough understanding of abstract classes where some concepts you may not aware of,…