Found 9326 Articles for Object Oriented Programming

Java Program to Access all Data as Object Array

Shriansh Kumar
Updated on 02-May-2023 17:31:52

75 Views

Array is a linear data structure that is used to store group of elements with similar datatypes. We can create an array with primitive datatypes and since a class is considered as user-defined datatype so it is also possible to create array of objects. In this article, we are going to discuss object array and we will create java program to access all data as object array. Object array or Array of Objects Array of objects actually contains reference variables of objects i.e. the elements stored in object array are of reference type. We follow the same syntax to create ... Read More

Java Program to Access All the Constant Defined in the Enum

Shriansh Kumar
Updated on 02-May-2023 17:30:28

98 Views

After JDK version 5 java introduces the enumeration. It is a group of constants defined using the keyword ‘enum’. The final variables in java are somewhat similar to enumeration. In this article, we will make a java program in which we define an enum class and try to access all the constant defined in the enum by using valueOf() and values() methods. Enum We use enum class when we need to define a fixed set of constants. For example, if we want to use the days of the week, planet names, names of all five vowels etc. Note that all ... Read More

Java Program to Check Array Bounds while inputting Elements into the Array

Shriansh Kumar
Updated on 02-May-2023 17:18:58

63 Views

Array is a linear data structure that is used to store group of elements with similar datatypes. It stores data in a sequential manner. Once we create an array we can’t change its size i.e. it is of fixed length. This article will help you to understand the basic concept of array and array bound. Also, we will discuss java program to check array bounds while inputting elements into the array. Array and Array Bound We can access elements of array by its index. Suppose we have an array of length N, then We can ... Read More

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

Shriansh Kumar
Updated on 02-May-2023 17:01:18

94 Views

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. 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. Syntax to declare a variable Data_Type nameOfvariable = values [optional]; ... Read More

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

Shriansh Kumar
Updated on 02-May-2023 16:57:38

94 Views

The type of nested inner class that has no name is called as anonymous class. Before making a java program to check if a given class is an anonymous class we need to understand the concept of nested class. Let’s discuss this in detail. Nested Class When we create class within another class, it is referred as nested class. The nested classes share the same scope. It allows the grouping of similar classes and it increases the encapsulation (encapsulation means wrapping of similar functionalities in a single unit). In java, we know that a class could not be defined with ... Read More

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

Shriansh Kumar
Updated on 02-May-2023 16:54:05

129 Views

The nested class that is defined inside the body of a method or within a loop like for and if, is called as 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 class. Let’s discuss this in detail. Nested Class When we create class within another class, it is referred as nested class. The nested classes share the same scope. It allows the grouping of similar classes and it increases the encapsulation (encapsulation means wrapping of similar functionalities in ... Read More

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

Shriansh Kumar
Updated on 25-Apr-2023 18:00:43

188 Views

Consider the following table for eligibility criteria of different companies − CGPA Eligible Company Greater than or equal to 8 Google, Microsoft, Amazon, Dell, Intel, Wipro Greater than or equal to 7 Tutorials point, accenture, Infosys, Emicon, Rellins Greater than or equal to 6 rtCamp, Cybertech, Skybags, Killer, Raymond Greater than or equal to 5 Patronics, Bata, Nobroker Let’s jump into the java program to check eligibility of tpp students for appearing in interviews. Approach 1: Using if else if condition Generally, we use if else if ... Read More

Java Program to Check if JVM is 32 or 64 bit

Shriansh Kumar
Updated on 25-Apr-2023 17:57:09

668 Views

Before making java program to check if JVM is 32 or 64 bit, let’s first discuss about JVM. JVM is java virtual machine that is responsible for executing the byte code. It is a part of Java Runtime Environment (JRE). We all know java is platform independent but the JVM is platform dependent. We need separate JVM for every OS. If we have byte code of any java source code, we can run it on any platform easily because of JVM. The whole process of execution of a java file is as follows − First, we save java ... Read More

Java Program to Check if a given Number is Perfect Number

Shriansh Kumar
Updated on 25-Apr-2023 17:55:15

957 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. In this article, we will create java programs to check if a given number is perfect or not. for the given problem we are going to use iterative approaches like for loop and while loop. Let’s try to understand through some examples − Example 1 Given number: 496 Its factors are: 1, 2, 4, 8, 16, 31, 62, 124 and 248 ( we have to exclude 496 ) Sum of the factors are: 1 + ... Read More

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

Shriansh Kumar
Updated on 25-Apr-2023 18:05:13

182 Views

In java, collection is an object or we can say a container for simplicity that allows us to group several numbers of objects in a single unit. The collection interface is present at the root of all collection framework interfaces. We can perform various operations on collection like adding, removing, iterating, searching and retrieving objects. In this article, we will discuss a java program to add data from the specified collection in the current collection with the help of addAll() and add() method. addAll() − It add data from a specified collection into current collection. Its return type is ... Read More

Advertisements