
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

1K+ Views
For a given character, say "ch", write a Java program to print its ASCII value. We can find the ASCII value of any character by assigning it to an integer value and printing that integer value. The term ASCII stands for American Standard Code for Information Interchange. There are 128 standard ASCII codes, each of which can be represented by a 7-digit binary number: 0000000 through 1111111. Extended ASCII adds an additional 128 characters that vary between computers, programs and fonts. Example Scenario: Input: character = s; Output: ascii_value = 115 Example 1 In this example, we are printing ... Read More

765 Views
The octal number system has a base value of 8 as it contains digits from 0 to 7, i.e., 8. On the other hand, the decimal number system has 10 digits from 0 to 9. Hence, its base value is 10. In this article, we will learn to convert decimals to the octal number system in Java. Problem Statement The goal is to write a program to convert a given decimal number (base 10) into its equivalent octal number (base 8). Example Scenario: Input: int decimalNumber = 8 Output: The octal value is = 10 Converting Decimal to Octal in ... Read More

1K+ Views
For a given rectangle of length l and width w, write a Java program to find its perimeter. The Perimeter of a rectangle is calculated by adding the lengths of all the sides of the rectangle. Below is a demonstration of a rectangle, a quadrilateral with four right angles (90°). The perimeter of a rectangle is the total length of the two lengths and two widths of the rectangle − Example Scenario: Input: length = 5, 8, 5, 8; Output: Perimeter = 26 On adding all the sides of rectangle, you will get perimeter. 5+8+5+8 = 26 Steps ... Read More

16K+ Views
In this article, we will understand how to calculate compound interest in Java. Compound interest is calculated using the following formula. Amount = P(1 + R/100)t Compound Interest = Amount - Principle where, P is the principal amount T is the time R is the rate Compound interest is the interest calculated on the initial principal and also on the accumulated interest of previous periods. In other words, Compound Interest = Interest on Principal + Interest on Interest. We'll learn how to get user input for the principal amount, interest rate, and time period, and then calculate the compound interest based ... Read More

3K+ Views
In this article, we will understand how to write a Java program to calculate simple interest. But, before doing it, let's understand how we calculate simple interest mathematically. The simple interest is a way to determine the amount of interest gained on a principal amount at the specified interest rate for a given time. Unlike compound interest, its principal amount does not change over time. To calculate Simple Interest, we use the following formula− Simple Interest (S.I) = Principal * Time * Rate / 100 where, P is the principal amount T is the time R is the rate ... Read More

3K+ Views
In this article, we will learn how to find the even sum of the Fibonacci series up to a given number N. A Fibonacci series is a series where the next term is the sum of the previous two terms. An even Fibonacci series is a group of all the even numbers in the Fibonacci series. The first two terms of the Fibonacci sequence are 0 and 1. Fn = Fn-1 + Fn-2 Hence, a Fibonacci series can look like this - F8 = 0 1 1 2 3 5 8 13 or, this F8 = 1 1 2 3 5 ... Read More

1K+ Views
In this article, we will understand how to check whether the given input number is a neon number. A neon number is such a number whose sum of digits of square of the number is equal to the number itself. Example Scenario: Input: num = 9; Output: The given input is a neon number How to Check Neon Number in Java? To check a given input is a neon number in Java, use the below approaches − Using for loop Using while loop Using recursion Using ... Read More

37K+ Views
In this article, we will understand how to display all the prime numbers from 1 to N in Java. All possible positive numbers from 1 to infinity are called natural numbers. A number is a prime number if its only factors are 1 and itself and cannot be divided by any other number. 11 is a prime number. Its factors are 1 and 11 itself. Some examples of prime numbers are 2, 3, 5, 7, 11, 13, and so on. 2 is the only even prime number. All other prime numbers are odd numbers. Below is a demonstration of the ... Read More

2K+ Views
In this article, we will understand how to get input from the user in Java. Java provides a built-in Scanner Class that belongs to the java.util package. The Scanner class is used to get user input. In this article, we will learn how to take different types of input, like integers, floating numbers, strings, etc., from the user in Java. Algorithm Following are the steps to get input from the user - Step 1- START Step-2- Import the Scanner class Step 3- Create a Scanner object Step 4- Prompt the user to enter ... Read More

2K+ Views
In Java, to read input from standard input(via keyboard), Java provides a built-in Scanner Class. In this article, we will understand how to read a number from standard input(via keyboard) in Java. The Scanner.nextInt() method of the Scanner class belongs to java.util package is used to read the number. The java.util.Scanner.nextInt() method scans the next token of the input as an int. The nextInt() method reads numbers in base-10 (decimal numbers) by default. To read numbers in other bases, like binary or hexadecimal, you can use nextInt(radix). Problem Statement Write a Java program to read a number from standard input. ... Read More