Java – Polymorphism

Polymorphism means having many forms. The word “poly” means many and “morphs” means forms. In java, it is a concept that allows the user to perform a single action in different ways. Take a real-life example: Consider a man and at the same time he can be a father, a husband, an employee that is he … Read more

Abstraction in Java

Data abstraction is the process of hiding the details but only displaying the relevant information to the users, which means hiding the implementation details and displaying only its functionalities. This is one of the main advantages of using abstraction. Abstraction is one of the four major concepts behind object-oriented programming (OOP). Real Life Example of Abstraction … Read more

Java – Types of Inheritance

Java supports three types of inheritance on the basis of class: single, multilevel, and hierarchical. Whereas multiple and hybrid inheritance is supported through interface only. Types of Inheritance in Java: Single Inheritance Multilevel Inheritance. Hierarchical Inheritance. Multiple Inheritance. Hybrid Inheritance. 1. Single Inheritance: It is a child and parent class relationship where a child class extends or … Read more

Java Encapsulation

Encapsulation is one of the four fundamental OOP concepts. Encapsulation in Java is defined as the wrapping up of data(variable) under a single unit. The use of Encapsulation is to make sure that implementation detail or we can say sensitive data is hidden from the users. For this, Encapsulation is also known as data hiding. Implementing the … Read more

Java – Object-Oriented Programming concept

Object-oriented programming: It is the concept of using objects in programming. It is a paradigm that uses objects and classes that aim to implement real-world entities. The entities such as inheritance, abstraction, polymorphism, etc that are used in programming. The main goal of an OOP is to tie together the data and its method in a single … Read more

Java – Inheritance

It is one of the main features of Object-Oriented Programming (OOP). Inheritance is one of the processes or mechanisms in OOP in which one class(sub-class) acquires the properties(data members) and functionalities(methods) of another class(parent-class). Importance of Inheritance: For Code Reusability. For Method Overriding (to achieve runtime polymorphism). Important terms: Super Class: The class whose properties and functionalities are … Read more

Java – call by value and call by reference

call by value in Java: If a method is to be called by passing a parameter as a value then it is said to be Call by Value. Here the changes made to the passed parameter do not affect the called method. Example of call by value: Output: call by reference in Java: If a … Read more

Java Keywords & Identifiers

Keywords: Keywords in Java are also known as reserved words, are already defined in Java with a predefined meaning. These words cannot be used with variables or object name. Example of using integer Keyword: List of Keywords used in Java are shown in the table: Keywords abstract assert boolean break byte case catch char do double else … Read more

Java – Type conversion/Type Casting

Type Casting is assigning a value of one data-type to a variable of another data-type. When a value is assigned to another variable, their types might not be compatible with each other to store that value. For this situation, they need to be cast or converted explicitly. But if they are compatible then java converts the … Read more

Java – Data Types

What are Data Types in Java? Data types specify the varying sizes and values in the variables that can be stored. That is every variable is assigned by data-types according to the need. And based on their respective data-types, the operating system allocates memory to that data-types. There are two data types in Java: Primitive data types: The … Read more