Found 7442 Articles for Java

Java Program to check the accessibility of an Instance Variable by a Static Method

Shriansh Kumar
Updated on 01-Sep-2025 12:12:46

168 Views

In Java, the static methods are defined using static keywords but to declare instance variables we don't use static keywords. Generally, we can't access the instance variable by a static method. In this article, we will create an instance variable and then we will check the accessibility of that instance variable by a static method. Let's understand static method and instance variable first. Java Instance Variable In the context of programming language, variables are the name of containers that contain data of any type. We can say it is a storage unit. A variable can be initialized at the time ... Read More

Java Program to Check if a given Class is an Anonymous Class

Shriansh Kumar
Updated on 19-Jun-2025 16:15:26

191 Views

The type of nested class that has no name is called an anonymous class. Before diving into a Java program to check if a given class is an anonymous class, we need to understand what is a nested class. Let's discuss this in detail. What is a Java Nested Class? A class created within another class in Java is called a nested class. We know that we cannot declare a Java class private, but we can define a nested class as private. There are two types of nested classes in Java: static and non-static. The static nested class is defined ... Read More

Java Program to Check if a given Class is a Local Inner Class

Shriansh Kumar
Updated on 30-May-2025 17:47:00

266 Views

The nested class that is defined inside the body of a method or within a loop, like for and if, is called a local inner class. Before making a Java program to check whether a given class is a local inner class or not, we need to understand the concept of nested classes first. Let's discuss this in detail. Nested Class When we create a class within another class, it is referred to as a nested class. The nested classes share the same scope. It allows the grouping of similar classes and encapsulation (wrapping of similar functionalities in a single unit). ... Read More

Java Program to check Eligibility of TPP students for appearing in Interviews

Shriansh Kumar
Updated on 06-Jun-2025 13:58:45

308 Views

Checking Eligibility of TPP Students in Java Consider the following table for eligibility criteria of different companies for appearing in interviews: CGPA ... Read More

Java Program to Check if JVM is 32 or 64 bit

Shriansh Kumar
Updated on 01-Aug-2024 11:01:47

840 Views

In this article, we will learn how to determine whether the installed JVM in your system is 32 bit or 64 bit. For this operation, we use the getProperty() method of System class, which helps in retrieving system property of specified argument. In computer architecture, 32 bit and 64 bit refers to those components that operate on data in 32-bit units and 64-bit units respectively. 64 bit machines are said to be faster and more secure compare to the 32 bit machines. What is JVM? JVM is Java Virtual Machine that is responsible for executing the byte code. It is ... Read More

Java program to check if a given number is perfect number

Shriansh Kumar
Updated on 06-Jun-2025 13:17:34

2K+ Views

When the sum of factors of a given number (after discarding the given number) is equal to the number itself is called a perfect number. The sum of these divisors is known as the aliquot sum. Therefore, we can say that a number is perfect if it matches its aliquot sum. All known perfect numbers are even. Problem Statement In this article, we will create Java programs to check if a given number is perfect or not. Let's try to understand the given problem through some examples: Example Scenarios: Input: number = 496 Output: 496 is a perfect number ... Read More

Java Program to Add the data from the Specified Collection in the Current Collection

Shriansh Kumar
Updated on 19-Jun-2025 16:01:31

287 Views

In Java, a collection is an object that allows us to group several numbers of objects as a single unit. The Collection interface is the root of the collection framework. We can perform various operations on collection like adding, removing, iterating, searching and retrieving objects. In this article, we will discuss Java programs to add data from the specified collection to the current collection with the help of addAll() method. Using addAll() method of Collection Interface The addAll() method of Collection interface adds data from a specified collection into current collection. It returns a boolean value, which is TRUE if the ... Read More

Java Program to Add the nth Square Series

Shriansh Kumar
Updated on 30-May-2025 17:29:59

299 Views

The sum of the nth squares series is a form of arithmetic progression where the sum of squares is arranged in a sequence with the initial term as 1, and n being the total number of terms. 12 + 22 + 32 + ... + n2 In this article, we will discuss a Java program to add the nth square series. But, before that, let's see an example scenario: Example Scenario: Input: num = 6 Output: sum = 91 It will be calculated as: 12 + 22 + 32 + 42 + 52 + 62 = 1 ... Read More

Java Program to Allocate and Initialize Super Class Members using Constructor

Shriansh Kumar
Updated on 06-Jun-2025 13:57:24

480 Views

In Java, super refers to the parent class instance, and to inherit members of the super class to the child class, we use the extends keyword. Before writing a Java program to allocate and initialize super class members using a constructor, let's go through some concepts we are going to use in this article. What is Constructor? A Java constructor is a class member that initializes instance variables of a class. It is very similar to a method, but the difference is that methods can return a value, but a constructor does not return any value because it can't have any return ... Read More

Java Program to Add two Numbers without using Arithmetic Operator

Shriansh Kumar
Updated on 19-Jun-2025 15:46:18

4K+ Views

Arithmetic operators such as "+", "-", "*", and "/" are used to perform mathematical operations like addition, subtraction, multiplication, modulo, and division. We have added two numbers using the "+" operator, but in this article, we are going to learn a few Java programs that can add two numbers without using arithmetic operators. The following operators best serve this purpose: Increment operators (++) Bitwise operators ... Read More

Advertisements