![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- 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 9326 Articles for Object Oriented Programming
![Chandu yadav](https://www.tutorialspoint.com/assets/profiles/22330/profile/60_142811-1519038104.jpg)
64K+ Views
Finding a year is a leap or not is a bit tricky. We generally assume that if a year number is evenly divisible by 4 is a leap year. But it is not the only case. A year is a leap year if −1. It is evenly divisible by 1002. If it is divisible by 100, then it should also be divisible by 4003. Except this, all other years evenly divisible by 4 are leap years.Algorithm1. Take integer variable year2. Assign a value to the variable3. Check if the year is divisible by 4 but not 100, DISPLAY "leap year"4. ... Read More
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
717 Views
Any whole number which is greater than 1 and has only two factors that is 1 and the number itself, is called a prime number. Other than these two number it has no positive divisor. For example −7 = 1 × 7Few prime numbers are − 1, 2, 3, 5, 7, 11 etc.Algorithm1. Take integer variable A2. Divide the variable A with (A-1 to 2)3. If A is not divisible by any value (A-1 to 2), except itself it is a prime number.4. Repeat this for all the numbers starting from 2 to the required limit.ExampleLive Demopublic class First100Primes { public static void main(String args[]){ for(int i = 2; i
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
2K+ Views
The transpose of a matrix is the one whose rows are columns of the original matrix, i.e. if A and B are two matrices such that the rows of the matrix B are the columns of the matrix A then Matrix B is said to be the transpose of Matrix A.To print the transpose of the given matrix −Create an empty matrix.Copy the contents of the original matrix to the new matrix such that elements in the [j][i] position of the original matrix should be copied to the [i][j] position of the new matrix.Print the new matrix.ExampleLive Demopublic class TransposeSample{ ... Read More
![Ankith Reddy](https://www.tutorialspoint.com/assets/profiles/22328/profile/60_142162-1519038074.jpg)
1K+ Views
In the loop check, the result of I %2 operation on each element, if 0 the element is even else the element is odd.ExampleLive Demopublic class OddNumbersInAnArray { public static void main(String args[]){ int[] myArray = {23, 93, 56, 92, 39}; System.out.println("Even numbers in the given array are:: "); for (int i=0; i
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
5K+ Views
To add two matrices −Create an empty matrixAt each position in the new matrix, assign the sum of the values in the same position from the given two matrices i.e. if A[i][j] and B[i][j] are the two given matrices then, the value of c[i][j] should be A[i][j] + B[i][j]ExampleLive Demopublic class AddingTwoMatrices{ public static void main(String args[]){ int a[][]={{1,2,3},{4,5,6},{7,8,9}}; int b[][]={{1,1,1},{1,1,1},{1,1,1}}; int c[][]=new int[3][3]; for(int i = 0;i
![Lakshmi Srinivas](https://www.tutorialspoint.com/assets/profiles/13528/profile/60_91717-1512651120.jpg)
13K+ Views
To find the smallest element of the given array, first of all, sort the array.Sorting an arrayCompare the first two elements of the arrayIf the first element is greater than the second swap them.Then, compare 2nd and 3rd elements if the second element is greater than the 3rd swap them.Repeat this till the end of the array.After sorting an array print the 1st element of the array.ExampleLive Demopublic class SmallestNumberInAnArray { public static void main(String args[]){ int temp, size; int array[] = {10, 20, 25, 63, 96, 57}; size = array.length; for(int i = 0; i
![Ankith Reddy](https://www.tutorialspoint.com/assets/profiles/22328/profile/60_142162-1519038074.jpg)
9K+ Views
To find the 2nd smallest element of the given array, first of all, sort the array.Sorting an arrayCompare the first two elements of the arrayIf the first element is greater than the second swap them.Then, compare 2nd and 3rd elements if the second element is greater than the 3rd swap them.Repeat this till the end of the array.After sorting an array print the 2nd element of the array.ExampleLive Demopublic class SmallestNumberInAnArray { public static void main(String args[]){ int temp, size; int array[] = {10, 20, 25, 63, 96, 57}; size = array.length; for(int i = 0; i
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
12K+ Views
To find the largest element of the given array, first of all, sort the array.Sorting an arrayCompare the first two elements of the arrayIf the first element is greater than the second swap them.Then, compare 2nd and 3rd elements if the second element is greater than the 3rd swap them.Repeat this till the end of the array.After sorting an array print the 1st element from the end of the array.ExampleLive Demopublic class ThirdLargestNumberInAnArray { public static void main(String args[]){ int temp, size; int array[] = {10, 20, 25, 63, 96, 57}; size = array.length; for(int i = 0; i
![Samual Sam](https://www.tutorialspoint.com/assets/profiles/13514/profile/60_83486-1512649303.jpg)
55K+ Views
To find the second largest element of the given array, first of all, sort the array.Sorting an arrayCompare the first two elements of the arrayIf the first element is greater than the second swap them.Then, compare 2nd and 3rd elements if the second element is greater than the 3rd swap them.Repeat this till the end of the array.After sorting an array print the second element from the end of the array.ExampleLive Demopublic class ThirdLargestNumberInAnArray { public static void main(String args[]){ int temp, size; int array[] = {10, 20, 25, 63, 96, 57}; size = array.length; for(int i = 0; i
![Arjun Thakur](https://www.tutorialspoint.com/assets/profiles/13574/profile/60_74441-1560315595.jpg)
10K+ Views
To find the third largest number of the given array, first of all, sort the array.Sorting an arrayCompare the first two elements of the arrayIf the first element is greater than the second swap them.Then, compare 2nd and 3rd elements if the second element is greater than the 3rd swap them.Repeat this till the end of the array.After sorting an array print the third element from the end of the array.ExampleLive Demopublic class ThirdLargestNumberInAnArray { public static void main(String args[]){ int temp, size; int array[] = {10, 20, 25, 63, 96, 57}; size = array.length; for(int i = 0; i