Java – Garbage Collection

Garbage collection in java is a way in which the unreachable objects are destroyed to free up space in memory. JVM creates a heap area which is called runtime data area, where all the objects are stored. And the space in that area is limited so it is needed to manage this area efficiently by … Read more

Java – Packages and its types with example

Packages in Java are a way to pack(group) a number of related types such as classes, interfaces, enumerations, and annotations together into a single unit. Think of it as a container for the classes. Packages are used to avoid name conflicts, provide a good structure to the projects with maintainable code that consists of many … Read more

Java – Method Overriding with Example, Super Keyword

In any object-oriented programming language, Method Overriding is a feature that allows the user to declare a method with the same name in a sub-class that is already present in a parent-class. That is when a sub-class inherits from its super-class and both have the same-named method than by overriding features, different tasks can be … Read more

Java – Method Overloading with Example

Method Overloading is one of the features in a class having more than one method with the same name. It is the same as Constructor Overloading in java. The methods are differed by their input parameter that is the data type, the number of parameters, and the order of the parameter list. Note that: Method overloading is not … Read more

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