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

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

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

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

What is Object Oriented Paradigm in Java?

The term Programming paradigm means the methodology for writing program codes. In general, two paradigms govern how you can construct a program. These two ways are: a process-oriented model an object-oriented model Many programming languages support both the paradigms like python. Python allows the users to code using both process-oriented and object-oriented methodologies. However, Java is exclusively object-oriented. What is Object Oriented Paradigm The object-oriented programming paradigm (OOP) has a completely different approach to problem-solving. It does not focus on the problem

Read more

Java Hybrid Inheritance With Example

Hello everyone, In this tutorial, we are going to learn about Hybrid inheritance in Java. Before diving right into hybrid inheritance let us first quickly look at some other types are inheritance commonly used in Java. As you may know, Java typically uses four types of inheritance: Single Inheritance Multilevel Inheritance Hierarchical Inheritance Multiple Inheritance Single Inheritance: When a class extends another one class we call it Single Inheritance. Here A is called the parent class and B is derived

Read more

Loose Coupling and Tight Coupling in Java

In this article you will learn about loose coupling and tight coupling in java. In simple words “Coupling is the degree of dependency between the modules or Routines.”  “In a software or program, the more modules or classes will communicate with each other means the more tightly they are coupled and on other hand, the less they communicate with each other, means the more loosely they are coupled. “ Should the modules of a software tightly coupled or loosely? So

Read more
1 2