
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 9178 Articles for Object Oriented Programming

378 Views
In this article, we will learn to generate all possible words from a string of phone digits using Java. Each digit on a mobile keypad corresponds to a set of letters, and our task is to find every possible combination of letters that can be formed by pressing those digits. For instance, if the input is "23, " the output would include combinations like "ad, " "ae, " "af, " and so on. We will implement a recursive approach to achieve this, allowing us to systematically generate and print all possible words corresponding to the given digits. Problem Statement Write ... Read More

456 Views
The task is to generate a string that consists of characters ‘a’ and ‘b’ which satisfies the condition mentioned below: str must have a length of A+B. The character 'a' must appear A times and the character 'b' must appear B times within the string. The sub−strings "aaa" and "bbb" should not appear in str. After generating the string, it should be printed. One possible solution is to first generate a string with all 'a's and 'b's, with 'a' occurring A times and 'b' occurring B times. Then, we can shuffle the string randomly until we find a ... Read More

196 Views
In this tutorial, we will learn how to find the maximum length of the subsequence having the same left and right rotations in Java. We find the maximum length of such subsequence. Finding the longest subsequence with identical or alternating digits We will solve the problem based on a particular observation. The strings can only have the same left and right rotations if all digits of strings are equal or it contains the two digits alternatively, and the string length is even. Step 1: Initialize Variables: Initialize the len variable with the string length and ... Read More

2K+ Views
A prime number is a positive integer greater than 1 that is only divisible by 1 and itself. Prime numbers are an essential concept in mathematics and computer science. They are integers that are only divisible by 1 and themselves. Finding prime numbers is an important task in many algorithms, and there are several methods to determine if a number is prime. One such problem is finding the closest prime number to a given number. Problem Statement For a given number find the closest prime number by using Java programming language. Consider the following example - Input ... Read More

3K+ Views
In Java, an ArrayList is a resizable array, which is implemented as part of the Java Collections Framework. It is a dynamic data structure that can hold any type of objects, including primitive types such as integers and characters. As per the problem statement we have to read a file into an ArrayList. First and foremost we will take the path of the file as input and then we will apply different method to read the file. Let's start!Example For instance Suppose the input file is “myfile.txt”. After reading the content of the file, the result ... Read More

12K+ Views
In Java, Timestamp can be converted Date by using Date class. Date class is present in java.util package. The constructor of the Date class receives a long value as an argument. Since the constructor of the Date class requires a long value, we need to convert the Timestamp object into a long value using the getTime() method of the TimeStamp class. Let's deep dive into this article, to know how it can be done by using Java programming language. To show you with instance Suppose the timestamp is 06/01/2023. Then corresponding Date is “Fri Jan ... Read More

1K+ Views
In Java, smaller datatype can be converted to bigger datatype. Here, we will see how to convert char datatype to int datatype. The char data type is a single 16-bit Unicode character. It has a minimum value of '\u0000' (or 0) and a maximum value of '\uffff' (or 65, 535 inclusive). The int data type is a 32-bit signed two's complement integer, which has a minimum value of -231 and a maximum value of 231-1. Let's deep dive into this article, to know how it can be done by using Java programming language. For instance Suppose the given ... Read More

392 Views
In Java, a matrix can be represented using a two-dimensional array. Matrices are used for storing and manipulating data that have a tabular structure. Matrices have several properties and operations associated with them, such as addition, subtraction, multiplication, transposition, and determinant calculation. As per the problem statement we have to Create a Matrix and Fill Primary Diagonal with 1 and Secondary Diagonal with 0. Let's start! For instance Suppose we have 4*4 matrix i.e. 4 rows and 4 columns. After performing the operation on matrix, the result will be: Enter the size of the matrix: ... Read More

291 Views
In Java, a matrix can be represented using a two-dimensional array. Matrices are used for storing and manipulating data that have a tabular structure. Matrices have several properties and operations associated with them, such as addition, subtraction, multiplication, transposition, and determinant calculation. As per the problem statement we have to Create a Matrix and Fill it with Palindrome Number. Let's start! For instance Suppose we have 4*5 matrix: After performing the operation on matrix, the result will be: Enter the number of rows: 4 Enter the number of columns: 5 Matrix with Palindrome ... Read More

211 Views
In Java, a matrix can be represented using a two-dimensional array. Matrices are used for storing and manipulating data that have a tabular structure. Matrices have several properties and operations associated with them, such as addition, subtraction, multiplication, transposition, and determinant calculation. As per the problem statement we have to Create a Matrix and Fill it with Armstrong Number. Let's start! For instance Suppose we have 4*3 matrix: After performing the operation on matrix, the result will be: Enter the number of rows: 4 Enter the number of columns: 3 Armstrong Matrix: ... Read More