Method in Java

Java Method is a collection of statements that are put together to perform some specific task. To run the methods, it should be called and it returns the value to the caller. Users can pass data to the methods and those data are known as parameters. They are also known as a function. It allows the … Read more

Inner Class in Java

Java Inner class is also known as the nested class is a class within the class, method, or block declared inside class or interface. The use of the inner class is to group the classes or interfaces logically in one place so that it becomes easy to read and maintain. Java Inner class is of two types: A. Non-static … Read more

Java – What are Access Modifiers?

The access modifiers in Java specifies the accessibility or visibility or scope of a field, method, constructor, or class. Java defines four access modifiers: Following shows their accessibility, default (Same class, Same package) private (Same class) protected ( Same class, Same package, Subclasses) public ( Same class, Same package, Subclasses, Everyone) 1. default: Default access modifiers mean, no modifiers … Read more

Java – Interface with Syntax and Example

An Interface in Java is the same as a class, like any other class, an interface can have methods and Variables. But unlike a class, the method in it is an abstract method (only method signature, contain no body), and also by default, the declared variables in an interface are public, static & final. Uses of Interfaces: It is used … Read more

Java – Constructor with Example

A constructor is a block of codes just like a method in Java. It is a special type of method that is called when an instance of the class (that is object) is created and is used for the initialization of the data members of a newly created object. There are some rules for Java constructor: … Read more

Java – Class and Objects with Example

Java is an Object-Oriented Language. And classes and objects are the fundamental components of OOP’s. Objects are real-life entity and classes are the blueprint for creating an object. For example: consider a class for a car, it has color, some weight, size, etc, these are its attributes and drive, gear, brake, etc are its behaviour. CLASS … Read more

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