Java Program to print Odd and Even Numbers from an Array9 Sept 2024 | 1 min read We can print odd and even numbers from an array in java by getting remainder of each element and checking if it is divided by 2 or not. If it is divided by 2, it is even number otherwise it is odd number. Test it NowOutput: Odd Numbers: 1 5 3 Even Numbers: 2 6 2 Next TopicJava Programs |
In this section, we will learn what is a mystery number and also create Java programs to check if the given number is a mystery number or not. The mystery number program frequently asked in Java coding tests and academics. Mystery Number A number N is said to...
3 min read
In this program, we need to create the binary tree by inserting nodes and displaying nodes in in-order fashion. A typical binary tree can be represented as follows: In the binary tree, each node can have at most two children. Each node can have zero, one...
4 min read
It is very interesting problem frequently asked in interviews of top IT companies like Google, Amazon, TCS, Accenture, etc. By solving the problem, one wants to check the logical ability, critical thinking, and problem-solving skill of the interviewee. So, in this section, we are going...
6 min read
In this program, we need to check whether all the leaves of the given binary tree are at same level or not. A Node is said to be leaf if it doesn't have any child node. In the below diagram, nodes 4, 5 and 6 are...
5 min read
In this section, we are going to solve another popular coding problem that was asked by e-commerce companies Flipkart and Amazon. Also, we will solve the problem with different approaches and create Java programs. Problem Statement In a boolean matrix of size m*n, we need to find if...
5 min read
In this program, we need to create a singly linked list and count the nodes present in the list. To accomplish this task, traverse through the list using node current which initially points to head. Increment current in such a way that current will point to...
6 min read
It is a very interesting problem frequently asked in interviews of top IT companies like Google, Amazon, TCS, Accenture, etc. By solving the problem, one wants to check the logical ability, critical thinking, and problem-solving skill of the interviewee. So, in this section, we are going...
7 min read
Java Convert Decimal to Binary We can convert decimal to binary in java using Integer.toBinaryString() method or custom logic. Java Decimal to Binary conversion: Integer.toBinaryString() The Integer.toBinaryString() method converts decimal to binary string. The signature of toBinaryString() method is given below: public static String toBinaryString(int decimal) Let's see the simple example...
1 min read
Java Convert Object to String We can convert Object to String in java using toString() method of Object class or String.valueOf(object) method. You can convert any object to String in java whether it is user-defined class, StringBuilder, StringBuffer or anything else. Here, we are going to see two examples...
1 min read
In this program, we create a circular linked list and insert a new node in the middle of the list. If the list is empty, both head and tail will point to new node. If the list is not empty, then we will calculate the...
8 min read
We request you to subscribe our newsletter for upcoming updates.
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India