Category Archives

Static blocks in Java

Unlike C++, Java supports a special block, called static block (also called static clause) which can be used for...

Static blocks in Java

Unlike C++, Java supports a special block, called static block (also called static clause) which can be used for...

Instance Variable Hiding in Java

In Java, if there is a local variable in a method with same name as instance variable, then the...

Instance Variable Hiding in Java

In Java, if there is a local variable in a method with same name as instance variable, then the...

Overriding toString() in Java

This post is similar to Overriding equals method in Java. Consider the following Java program: // file name: Main.java...

Overriding toString() in Java

This post is similar to Overriding equals method in Java. Consider the following Java program: // file name: Main.java...

Overriding equals method in Java

Consider the following Java program: class Complex { private double re, im; public Complex(double re, double im) { this.re...

Overriding equals method in Java

Consider the following Java program: class Complex { private double re, im; public Complex(double re, double im) { this.re...

Flexible nature of java.lang.Object

We all love the mechanism of python, where we don’t have to bother about data types of the variables...

Flexible nature of java.lang.Object

We all love the mechanism of python, where we don’t have to bother about data types of the variables...

Static class in Java

Can a class be static in Java? The answer is Yes, some classes can be made static in Java....

Static class in Java

Can a class be static in Java? The answer is Yes, some classes can be made static in Java....

Object class in Java

Object class is present in java.lang package. Every class in Java is directly or indirectly derived from the Object...

Object class in Java

Object class is present in java.lang package. Every class in Java is directly or indirectly derived from the Object...

Covariant return types in Java

Before JDK 5.0, it was not possible to override a method by changing the return type. When we override...

Covariant return types in Java

Before JDK 5.0, it was not possible to override a method by changing the return type. When we override...

Assigning values to static final variables in Java

Assigning values to static final variables in Java: In Java, non-static final variables can be assigned a value either...

Assigning values to static final variables in Java

Assigning values to static final variables in Java: In Java, non-static final variables can be assigned a value either...

Static methods vs Instance methods in Java

Instance method are methods which require an object of its class to be created before it can be called....

Static methods vs Instance methods in Java

Instance method are methods which require an object of its class to be created before it can be called....