Shriansh Kumar has Published 324 Articles

Java public static void main(String[] args)

Shriansh Kumar

Shriansh Kumar

Updated on 19-Jun-2025 11:48:14

9K+ Views

The Java program starts execution when the JVM calls the main() method. A Java application begins with this method. Without a main() method, a Java file will compile successfully because at compile time, the compiler doesn't check for a main method, but at run time JVM checks whether the main() method ... Read More

Java program for Hexadecimal to Decimal Conversion

Shriansh Kumar

Shriansh Kumar

Updated on 19-Jun-2025 10:27:47

1K+ Views

The given task is to write a Java program to convert it into its equivalent decimal number system. The base value of hexadecimal is 16, and decimal is 10. When we convert the hexadecimal to decimal, the base value 16 will be changed to 10. The number system is of ... Read More

Java Program to Calculate difference between two Time Periods

Shriansh Kumar

Shriansh Kumar

Updated on 19-Jun-2025 10:19:22

824 Views

We are given two time periods, and our task is to write a Java program to calculate the difference between them. For this problem, we can use classes and methods of java.time, java.util, and java.text packages. SimpleDateFormat class Date class ... Read More

Java Program to Check Whether a Number can be Expressed as Sum of Two Prime Numbers

Shriansh Kumar

Shriansh Kumar

Updated on 19-Jun-2025 10:12:31

1K+ Views

The given task is to write a Java program to check if an integer can be expressed as the sum of two prime numbers. A number is said to be a prime if it has only two factors, which are 1 and itself, and cannot be divided by any other ... Read More

Java Program to Check if two strings are anagram

Shriansh Kumar

Shriansh Kumar

Updated on 18-Jun-2025 19:11:41

5K+ Views

An anagram is a word or phrase formed by rearranging the letters of two or more words. Suppose there are two strings. If both strings contain the same set of letters along with the same number of letters, regardless of their order, then we can say that both strings are ... Read More

Java Nested Loops with Examples

Shriansh Kumar

Shriansh Kumar

Updated on 18-Jun-2025 19:09:16

2K+ Views

Loops in Java are called control statements because they decide the flow of execution of a program based on some condition. Java allows the nesting of loops. When we put a loop within another loop, then we call it a nested loop. Nested loops are used when we need to iterate ... Read More

Java Program to Reverse a Number

Shriansh Kumar

Shriansh Kumar

Updated on 18-Jun-2025 19:05:39

1K+ Views

For a given input number, write a Java program to reverse its digits. In reverse operation, we print the digits of given number from the last to start. The digit at the last position is swapped with the digit at the first position, the second last digit is swapped with ... Read More

Java Program to Calculate Interest for FDs and RDs using Inheritance

Shriansh Kumar

Shriansh Kumar

Updated on 06-Jun-2025 14:04:57

872 Views

Inheritance is a concept that allows us to access the properties and behaviors of one class in another class. The class whose methods and member variables are inherited is known as the super class or parent class, and the class that inherits these methods and member variables is known as ... Read More

Java Program to Count the Number of Vowels and Consonants in a Sentence

Shriansh Kumar

Shriansh Kumar

Updated on 06-Jun-2025 14:00:42

2K+ Views

To count number of vowels and consonants in a given String, we can use the switch statement and if-else condition in Java. Alphabets that include 'a' 'e' 'i' 'o' 'u' are called Vowels and all other alphabets are called Consonants. Let's understand the problem statement with an example scenario. Example ... Read More

Can we create an object of an abstract class in Java?

Shriansh Kumar

Shriansh Kumar

Updated on 06-Jun-2025 13:59:55

15K+ Views

No, we can't create an object of an abstract class. But, we can create a reference variable of an abstract class. The reference variable is used to refer to the objects of derived classes (subclasses of abstract class). An abstract class hides the implementation and shows the function definition to ... Read More

Advertisements