Advantages and Disadvantages of Inheritance in Java

Inheritance is one of the pillars of the Java programming language. Learning OOP (Object Oriented Programming) without knowing and understanding the concept of Inheritance, its pros and cons are incomplete. Inheritance is a process in which a class acquires all the data members and its parent class methods. The basic idea behind it is that you create new classes based on the existing classes with additional data and methods. Example:

In the above example, there are two classes SuperHello

Read more

Java 3D Array – Three Dimensional Array

When you want to store a student’s list from a class and suppose the class consists of 100 students. By putting the data one by one into a variable will be time taking. While working with those variables and working with variables seems quite complicating and annoying. Therefore to avoid such a situation, an array is introduced, which can store data in a regular format. It is because of the array that operating on data became more accessible. First, get

Read more

Does Constructor Return Any Value?

To find out whether constructor returns any value or not, let’s learn about a constructor? In simple terms, the constructor is a special method, which is used to initialize an instance of a class. This special method differs from the actual methods of classes. The name of a constructor is always similar to the name of the class. Below is an example of a constructor:

How Constructor Work? Consider an example:

OUTPUT: Hello constructor The object is built

Read more

What is Native Method in Java?

Java uses various concepts to maintain privacy, structural format, and handling data efficiently, and many others. From all these concepts, one is to increase portability. To make the programs in Java more portable across all the platforms, the Java native interface (JNI) concept comes into the frame. JNI give out a bridge between Java and other native application. JNI is a segment of JDK (Java Development Kit), where JDK prefaces the java bytecode and the native programs (C and C++)

Read more

Why main method is static in Java?

One of the well-establish and most common programming languages is Java. Java came into existence in 1995. And to that date, C and C++ languages consistently widespread in the world of computer science. The ambition to make Java is to build familiarity, security, and portability of data. The main reason to make Java language is to make application programs independent of the hardware system to which the program is running. JVM (Java virtual machine) comes under the category of Abstract

Read more

Difference between Constructor and Method in Java

Java is an Object-Oriented Programming language. Therefore, the data and the member functions in Java are present in the classes. The classes in Java contain both constructors and methods as well. Let’s see in detail about methods and constructors and their differences. Constructor The purpose of constructors is to initialize the objects, which are the instances of the classes. Similar to the methods, the constructors also hold statement blocks that get executed during the run time of the program. Constructors

Read more

What is the Purpose of Default Constructor in Java

In object-orientated programming, the constructor plays an important role. A constructor is similar to the member functions of the class. However, their signature and purpose differ. The constructors have no return type, unlike the methods. Also, the constructor name always matches with the class, which makes it easily identifiable. In general, there are three types of constructors: Default Constructor No-Argument Constructor Parameterized Constructor Out of these, the default constructor is a constructor which the java compiler itself includes within the

Read more

Types of Constructors in Java

When you listen to the name Constructor, then what comes to your mind? Something like making or creating or building something. A constructor is also similar, it initializes an object immediately after its creation. You can compare constructors with the methods. They are similar while differing in some aspects. Constructors don’t have any return type, unlike the methods. Also, the Constructor name must be the same as the class name, which is not possible when declaring methods. 

Rules for

Read more
1 2