Found 9150 Articles for Object Oriented Programming

How To Check Whether a Number is Strontio Number or Not in Java?

Mr. Satyabrata
Updated on 09-Dec-2022 10:19:14

3K+ Views

A number is said to be a Strontio number, if we multiply 2 with a four-digit number then in the resultant number the tens place and hundreds place digits are the same. In simple terms, Strontio numbers are basically four-digit numbers. When we multiply 2 with it, it results in a number whose tens place and hundred places are exactly the same. Some examples of Strontio numbers are- 1111, 2222, 3333, 4444, 5555, 6666, 7777, 8888, 9999, 1001 ... etc. In this article, we will see how to check if a number is a strontio number by using Java ... Read More

How To Check Whether a Number is Pointer Prime Number or Not in Java?

Mr. Satyabrata
Updated on 09-Dec-2022 10:17:02

874 Views

A number is said to be a pointer prime number, if the sum of the product value of digits and the original prime number results in the next prime number. For more clarification, we take a prime number and multiply the digits with each other and add that multiplication value with the original number. After that if we get another prime number which is next to the original prime number. Then we can say that the number is a pointer prime number. Some examples of pointer prime numbers are: 23, 61, 1123, 1231 ... etc. In this article, ... Read More

How To Check Whether a Number is a Narcissistic Number or Not in Java?

Vivek Verma
Updated on 28-Aug-2025 15:47:12

3K+ Views

What is a Narcissistic Number? A number is said to be a Narcissistic number, only if the addition (or sum) of the value of each digit raised to the power of the total number of digits available in the original number is equal to the original number. Examples of narcissistic numbers, such as 153, 1634, 54748, etc. All single-digit numbers (0, 1, 2, 3, 4, 5, 6, 7, 8, 9) are Narcissistic numbers because the power of 1 of any digit will be the digit itself. The following input and output scenarios will help you understand the problem and calculation ... Read More

How To Check Whether a Number is a Mersenne Number or Not in Java?

Vivek Verma
Updated on 23-Jun-2025 10:40:19

2K+ Views

What is a Mersenne Number? A Mersenne number is a positive integer that is obtained using the expression M(n)= 2n-1, where 'n' is an integer. If you keep any value of n (e.g., 0, 1, 2, 3) in the above expression, the result will be a Mersenne number. For example, consider n = 2 and calculate the expression 22 - 1. The result is 3, which is a Mersenne number. Not all Mersenne numbers are prime (e.g., 24 - 1 = 15) is a mersenne number, which is not prime. Here are some other examples of Mersenne numbers: ... Read More

How To Check Whether a Number is an Empire Number or Not in Java?

Vivek Verma
Updated on 13-Jun-2025 12:08:36

438 Views

What is Empire Number? A number is said to be an Empire number if it is a prime number, and when we reverse that number, we should get another prime number. For example, let's consider the number 17. We know that 17 is a prime number, and if we reverse this number, we get 71, which is also a prime number. Therefore, 17 is known as an empire number. Here are some other examples of prime numbers such as 11, 13, 17, etc. Input & Output Scenarios Below are a few input and output scenarios that help to understand the ... Read More

Different methods to append a single character to a string or char array in Java

Janani Jaganathan
Updated on 25-Aug-2022 09:06:21

844 Views

Have you ever faced the situation of extending a string or char array? If you haven't yet, you might probably encounter this situation in the future. It is a common practice to append a single character to a string or char array in Java. The significant difference between a string array and a char array is that a string array is a sequence of characters, and a char array is a sequence of collection of data type char. String array runs as a single entity, whereas char array runs as a separate entity. In this blog, we will look ... Read More

Top Resources for Java Interview Questions

Janani Jaganathan
Updated on 25-Aug-2022 09:06:56

407 Views

Are you a fresher or final-year graduate looking to start your career as a Java developer? Have you already landed as a java developer and are looking to prepare for the next company? If you say "Yes" to any of these questions, then you are at the right place. In this article, you will come across the top resources and websites that will help you to prepare and do well in java programming interviews. The list includes popular online platforms and websites like Tutorialspoint, StackOverflow, DZone, etc., where you can learn frequently asked java questions in top companies' interviews and ... Read More

How to use List size() method in Java With Examples?

Vivek Verma
Updated on 26-May-2025 19:39:42

589 Views

In Java, a List is an interface which stores a sequence of elements of similar types. Since the list contains multiple elements, we might need to know how many element the list currently have. To count the total number of elements present in a list, the List interface provides a method named size(). The List size() Method The size() method of List interface is used to retrieve size of the current List. The size refers to total number of items currently the list holds. For example, a list have {1, 2, 3}, then the size of the list will be ... Read More

How to get sublist of List in Java?

Vivek Verma
Updated on 26-May-2025 19:42:36

7K+ Views

In Java, a List is an interface that stores elements of the same type. You can retrieve a sub-list from a List in Java. A sub-list is the view of a portion (or part) of the List. For example, if the given list is {a, b, c, d, e}, then the possible sub-lists can be {a, b}, {a, b, c}, {b, c, d}, {d, e}, etc. The List interface in Java provides a built-in method named subList(), which returns a sub-list from the given List. We just need to specify the range of extraction. Sublist from a List using the ... Read More

How to remove an element from a Java List?

Vivek Verma
Updated on 26-May-2025 19:20:28

5K+ Views

In Java, List is an interface that stores a sequence of elements of similar types. Like an array, elements in the list are stored at a specific index starting at 0. Since we can access elements in the list through their index, and we can pass this index value to the remove() method (i.e., a basic method for removing elements), which will remove the element at the specified index. We can remove an element from the List in Java: Using remove() Method of List Interface Using remove(object) Method ... Read More

Advertisements