Found 9326 Articles for Object Oriented Programming

Java Program to Find out the Area and Perimeter of Rectangle using Class Concept

Shiva Keerthi
Updated on 31-May-2024 16:30:49

4K+ Views

Java Language is one of the most used popular object - oriented programming language in present world. Class concept is one of the most important feature in Object - oriented languages. A Class is a like a blue print of an object. For example, when we want to build a house we first create a blue print of the house in other words we create a plan showing how we are going to build the house. Based on the plan we can create a number of houses. Similarly using class, we can create a number of objects. A class ... Read More

Java Program to Find Maximum Odd Number in Array Using Stream and Filter

Shiva Keerthi
Updated on 10-Apr-2023 16:40:22

963 Views

In this section, we are going to write a Java Program to Find Maximum Odd Number in an Array Using Stream and Filter. Odd numbers are the numbers which cannot be divided by ‘2’ or these numbers give remainder as 1 when they are divided by ‘2’. In other terms which can be written in the form of ‘2n+1’. We will find the Maximum Odd number in the array. Examples Input: array = {1, 7, 2, 3, 9, 5, 10} Output: Maximum odd number is 9 From the above example, in the array the maximum odd number is 9. ... Read More

Java Program to Find Harmonic Series

Shiva Keerthi
Updated on 10-Apr-2023 18:24:51

590 Views

The reciprocals of an arithmetic series without considering 0 is known as Harmonic series. If $a_{1}, a_{2}, a_{3}$… is arithmetic series then $\frac{1}{a1}$, $\frac{1}{a2}$, $\frac{1}{a3}$, … is the harmonic series. In this article, we will discuss how to implement a java program to find the harmonic series. Harmonic Series For 1st term n = 1 and for every term n is incremented by 1 and at last the nth term the value is ‘n’. Harmonic series : $1+\frac{1}{2}+\frac{1}{3}$.......+$\frac{1}{n}$ Where, 1/n is the nth term of harmonic series. Examples Harmonic Series: $\frac{1}{1}+\frac{1}{2}+\frac{1}{3}+\frac{1}{4}+.............\frac{1}{n}$ Example 1 Input: n = 4 ... Read More

Java Program to Find Area of Rectangle Using Method Overloading

Shiva Keerthi
Updated on 10-Apr-2023 16:21:05

1K+ Views

We can calculate the area of the rectangle in Java using Method Overloading. “Method Overloading” is a feature in Java that allows one to write more than one method in the same class using the same method name. It will enable us to declare more than one method with the same names but with different signatures i.e., the number of parameters in the method may be different or the datatype of parameters may be different. Method Overloading helps us to increase the readability of the code so that we can use the same method in different ways. Now, let us ... Read More

Java Program to Find G.C.D and L.C.M of Two Numbers Using Euclid's Algorithm

Shiva Keerthi
Updated on 10-Apr-2023 16:20:17

2K+ Views

Euclid’s Algorithm is an efficient algorithm which helps us to find G.C.D and L.C.M of two numbers. In this article, we are learning to write a Java program to find the G.C.D and L.C.M of two numbers using Euclid’s Algorithm. G.C.D. of two numbers G. C. D, known as Greatest Common Divisor is the highest common factor that divides the two given numbers exactly. Now let us look into an example and calculate the G.C.D of a two numbers. Factors − In mathematics, Factors are the numbers that can divide a given number. Ex − 8 can be divided ... Read More

Java Program to Find Chromatic Index of Cyclic Graphs

Shiva Keerthi
Updated on 10-Apr-2023 16:19:02

120 Views

Chromatic Index of a graph is the parameter which indicates the minimum number of colours needed to colour all the edges of graph such that no two edges sharing the common vertex have same coloured edge. In this article, we will discuss how to find the chromatic index of cyclic graphs using the Java programming language. What is a Cyclic Graph? Cyclic Graph is a graph which consists of at least one cycle path in that particular graph. Cyclic path is a path that starts from a specific node and ends at the same node. What is Graph Colouring? ... Read More

Java Program to Find Common Elements Between Two Arrays

Shiva Keerthi
Updated on 31-May-2024 15:06:05

6K+ Views

We can use different approaches in Java to Find Common Elements between two arrays. We will discuss the approaches, including the basic steps involved, and provide the necessary code to achieve our goal. Whether you are a beginner or an experienced Java programmer, this article will provide you with the tools and knowledge necessary to solve this common programming problem. In this article, we will learn different ways of finding the common elements between two arrays. Examples for Common Elements Between Two Arrays: Example 1: Input: array1 = {4, 2, 3, 1, 6} array2 = {6, 7, 9, ... Read More

Java Program to Find Cube Root of a number using Binary Search

Shiva Keerthi
Updated on 10-Apr-2023 16:13:54

676 Views

Cube Root of a number is an integer value when multiplied by itself thrice, gives the original number. In this article, we are going to write a java program to find the cube root of a number using binary search. Finding cube root of a number is one of the application of the binary search algorithm. We will discuss in detail how we calculate the cube root using binary search in this article. Input-Output Examples Example-1: Input: 64 Output: 4 As, the cube root of 64 is 4, the output is 4. Example-2: Input: 216 ... Read More

Java Program to Find Area of circle Using Method Overloading

Shiva Keerthi
Updated on 04-Jul-2024 17:49:37

1K+ Views

We can calculate the area of the circle in Java using Method Overloading. “Method Overloading” is a feature in Java that allows one to write more than one method in the same class using the same method name. It will enable us to declare more than one method with the same names but with different signatures i.e., the number of parameters in the method may be different or the datatype of parameters may be different. Now, let us achieve Method Overloading in Java by considering the “area of a circle” as an example. Before moving to an example, now ... Read More

Java Program to Find the GCDs of given index ranges in an array

Rudradev Das
Updated on 06-Apr-2023 15:22:34

176 Views

In the field of data structure, a range query is a pre-processing method to operate on some input data in an efficient manner. A range query is responsible to answer any query of the particular input on any data subset. If we want to copy some data columns from a table we need to maintain an index for that particular dataset. An index is a direct link or a key, which is designed to provide an efficient searching process in a data set. It is mainly used to speed up the data retrieving from a lost data source. In mathematics, ... Read More

Advertisements