
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 9150 Articles for Object Oriented Programming

846 Views
In this article, we will understand how to print the left triangle star pattern using Java. The pattern is formed by using multiple for-loops and print statements. Problem Statement Write a Java program to print the left triangle star pattern. Below is a demonstration of the same − Input Enter the number of rows : 8 Output The right triangle star pattern : * * * ... Read More

995 Views
In this article, we will understand how to print the left triangle star pattern in Java. This pattern is also known as the Mirrored Right Triangle Star pattern. Below is a demonstration of the same- Input: Number of rows: 6 Output: * * * * * * * * * * * * * * * * * * * * * Printing Left Triangle Star Pattern Following are the ... Read More

27K+ Views
Given a number, let's say N, write a Java program to check whether the given number is prime or not. Prime numbers are special numbers with only two factors 1 and that number itself, they cannot be divided by any other number. Example Scenario 1 Input: num = 1; Output: 1 is not a prime number Example Scenario 2 Input: num2 = 5; Output: 5 is a prime number 5 is divisible by 1 and 5 only Checking Prime Numbers using Factorization The naive approach to check a given number is prime or not is factorization. ... Read More

5K+ Views
An anagram is a word or phrase formed by rearranging the letters of two or more words. Suppose there are two strings. If both strings contain the same set of letters along with the same number of letters, regardless of their order, then we can say that both strings are anagrams; otherwise, not. Now, let's understand how we can find if two strings are anagrams or not in Java. How to Check if two Strings are Anagram? Follow the steps given below to solve the Anagram String problem: ... Read More

14K+ Views
In number theory, an Armstrong number is a pattern-based number whose sum of each digit raised to the power of total number of digits is equal to the given number itself. This article aims to explain Java programs that checks whether the given number is Armstrong or not. How to Check Armstrong Number? To check whether a number is an Armstrong or not, first, determine the total number of digits and assume it 'n'. Then separate each digit and raise them to the power of 'n'. In the last step, calculate the power of each digit and add all ... Read More

1K+ Views
In this article, we will understand how to check if an array contains a given value using two methods: Linear search and the HashSet class. For Linear Search, we will iterate through the array elements, comparing each element with the given input. For the HashSet class, we will utilize the contains() method to achieve this efficiently. Problem Statement Write a Java program to check if an array contains the given value − Input 1 Enter the number to be searched: 25 The elements in the integer array: 15 20 25 30 35 Output 1 The array contains the given value ... Read More

1K+ Views
In this article, we will learn to check whether the number is positive or negative in Java. To check whether the specified number is positive or negative can be determined with respect to 0. A number greater than 0 is considered a positive number whereas a number less than 0 is considered a negative number, we can use Java conditional statements like if-else-if blocks or ternary operators. Before that let's discuss the problem statement with the help of examples − Problem Statement Given an integer number as an input, write a Java program to check whether the number is positive ... Read More

1K+ Views
We are given an integer number as input, and our task is to write a Java program to check whether that number is even or odd. If a number is divisible by 2, then it is an even number otherwise, it is odd. To verify a given number is even or odd in Java, we can use 3 different ways one with the modulus operator (%), another with the bitwise AND operator (&), and a third one using a switch statement. Example Scenarios: Let's understand the problem statement with some example scenarios: Input: number = 45 Output: result = odd ... Read More

578 Views
In this article, we will learn how to find the sum of N numbers using recursion in Java. Recursion is when a method calls itself repeatedly until a base condition is met. In Java, each recursive call is placed on the stack until the base case is reached, after which values are returned to calculate the result. To solve with recursion, we need to divide our problem into smaller chunks, then find out solution for that smaller part, and that will be our base condition. In this problem, to find the sum of N numbers using recursion, we can store ... Read More

709 Views
In this article, we will understand how to find the product of two numbers using recursion in Java. A recursive function is a function that calls itself multiple times until a particular condition is satisfied. Product of two Numbers Using Recursion Recursion is the process of repeating items in a self-similar way. In programming languages, if a program allows you to call a function inside the same function, then it is called a recursive call of the function. To find the product of two numbers, let's say a and b, using recursion, the base case will be (if y = 0, ... Read More