
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

2K+ Views
In this program, we find the length of the longest increasing subsequence (LIS) in an integer array using Java programming language. An increasing subsequence is a sequence of numbers where each number is greater than the previous one. The program uses a dynamic programming approach to compute the longest increasing subsequence efficiently. This technique involves building a solution using previously computed results. Problem Statement Write a Java program to get the length of the longest increasing subsequence − Input 10, 22, 9, 33, 21, 50, 41, 60 Output The length of the longest increasing subsequence is 5 Steps get ... Read More

1K+ Views
Following is the Java program to print Triangle pattern −Example Live Demoimport java.util.*; public class Demo{ public static void main(String[] args){ Scanner my_scan = new Scanner(System.in); System.out.println("Enter the number of rows which needs to be printed"); int my_row = my_scan.nextInt(); for (int i = 1; i = i; j--){ System.out.print(" "); } for (int j = 1; j

1K+ Views
Following is the Java program to print integer between Strings −Example Live Demopublic class Demo{ public static void main(String[] args){ System.out.println("The equals symbol is present between two integer values "); System.out.println(45+5 + "=" +(56+11)); System.out.println(45+5 + " equals symbol " +(56+11)); } }OutputThe equals symbol is present between two integer values 50=67 50 equals symbol 67A class named Demo contains the main function that prints integer values between two strings.

1K+ Views
Following is the code to rename multiple files using Java −Exampleimport java.io.File; import java.io.IOException; public class Demo{ public static void main(String[] argv) throws IOException{ String path_to_folder = "path\to\folder\where\multiple\files\are\present"; File my_folder = new File(path_to_folder); File[] array_file = my_folder.listFiles(); for (int i = 0; i < array_file.length; i++){ if (array_file[i].isFile()){ File my_file = new File(path_to_folder + "\" + array_file[i].getName()); String long_file_name = array_file[i].getName(); String[] my_token = long_file_name.split("\s"); ... Read More

3K+ Views
Following is the code to clear screen using Java −Example Live Demopublic class Demo{ public static void main(String[] args){ System.out.print("\033[H\033[2J"); System.out.flush(); } }OutputThe screen would be clearedA class named Demo contains the main function. Here, the ANSI escape code is written, that clears the screen. The flush function resets the cursor to the top of the window screen.

2K+ Views
For a given input number, write a Java program to check if it is a Fibonacci number. Any number that belongs to Fibonacci series is called as Fibonacci number. The Fibonacci series is a sequence of numbers formed by the sum of its two previous integers. The first two terms of this series are 0 and 1 and further terms go like 1, 2, 3, 5, 8 and so on. This series was named after a famous Italian mathematician, Leonardo Fibonacci. Example Scenario 1 Input: num1 = 8; Output: 8 is a Fibonacci number 8 comes into ... Read More

628 Views
In this article, we will learn to calculate the GCD of more than two numbers in Java. We will discuss two approaches, the recursive method and an optimized approach using the Euclidean algorithm. The Greatest Common Divisor (GCD) of two or more integers is the largest integer that divides all the numbers without leaving a remainder. When it comes to an array of numbers, finding the GCD means determining the GCD of all the elements in the array. Problem Statement Given an array of integers, find the GCD of all the elements.Example −Input {7, 49, 177, 105, 119, 42} Output ... Read More

286 Views
In this article, we will learn two different approaches to computing the focal length of a spherical mirror using Java. While the second method makes use of Object-Oriented Programming (OOP) concepts for a more generic and flexible approach the first method is a simple functional implementation. Finding Focal Length Spherical mirrors play a vital role in optical systems, from telescopes and microscopes to vehicle rearview mirrors. These mirrors, either concave or convex, focus or diverge light, respectively, based on their geometry. The focal length, a key characteristic of spherical mirrors, determines how the mirror bends light.The focal length of a ... Read More

195 Views
Following is the Java program to find the vertex, focus and directrix of a parabola −Example Live Demopublic class Demo{ public static void find_values(float val_1, float val_2, float val_3){ System.out.println("The value of vertex is (" + (-val_2 / (2 * val_1)) + ", "+ (((4 * val_1 * val_3) - (val_2 * val_2)) / (4 * val_1)) + ")"); System.out.println("The value of focus is (" + (-val_2 / (2 * val_1)) + ", " + (((4 * val_1 * val_3) - (val_2 * val_2) + 1) / (4 * val_1)) + ")"); ... Read More