Showing posts with label Java Programs. Show all posts
Showing posts with label Java Programs. Show all posts

Thursday, September 5, 2024

Java Program To Reverse A String Without Using String Inbuilt Function reverse()

1. Introduction


In this tutorial, You'll learn how to write a java program to reverse a string without using string inbuilt function reverse().
This is a very common interview question that can be asked in many forms as below.

A) java program to reverse a string without using string inbuilt function
B) java program to reverse a string using recursion
C) java program to reverse a string without using the reverse method
C) Try using other classes of Java API (Except String).



The interviewer's main intention is not to use the String class reverse() method.

Friday, January 7, 2022

Java Program To Find First Non-Repeated Character In String (5 ways)

1. Overview


In this article, We will be learning and understanding the various ways to find the first non repeated character in a given string in various ways along with Java 8 Streams. Many programs may face this type of question in programming interviews or face to face round.
Let us start with the simple approach and next discover the partial and single iteration through the string.

Java Program To Find First Non-Repeated Character In String (5 ways)


Thursday, January 6, 2022

Latest 20+ JMS Interview Questions and Answers

1. Introduction


In this tutorial, We'll learn about JMS interview questions that are frequently asked in 2020. As part of the interview, There are chances to ask some of the questions on JMS area if you have 6 years plus. But, even less experience, it is good to have in the profile on JMS experience. The interviewer will check as messaging is a key aspect of enterprise Java development.
JMS is a popular open-source Messaging API and many vendors such as Apache Active MQ, Websphere MQ, Sonic MQ provides an implementation of Java messaging API or JMS.


Usually, Any interview starts with a basic. If all questions are answered properly then we will go onto the JMS experience project-based questions.

Basics mean What is Topic? What is the Queue? What is Publisher? What is Subscriber? What are a Publisher and Subscriber model? How to configure MQ?
Next level means Questions on a project where you have implemented JMS concepts?

Tuesday, December 28, 2021

Java Program to Check Leap Year (With Examples)

1. Overview

In this tutorial, you'll learn how to check the given year is a leap year or not.

Everyone knows that leap year comes for every 4 years and February month with 29 days.

But, when we do the logic in java it is bit different and should know the complete formula to evaluate leap year.


Java Program to Check Whether an Alphabet is Vowel or Consonant

1. Overview

In this tutorial, you'll learn how to check the given alphabet is a vowel or consonant in java.

We are going to solve this question using if else and switch statements.

To understand the programs in this article, you should have knowledge on the following topics.





Wednesday, December 22, 2021

Java Program to Calculate Standard Deviation

1. Overview

In this tutorial, you'll learn how to calculate the standard deviation in java using for loop and its formula.


2. Example to calculate standard deviation

Let us write a simple java program to find the standard deviation for an individual series of numbers.

First create a method with name calculateStandardDeviation(). Create an array with integer values and. pass this array to the calculateStandardDeviation() method. This method has the core logic to get the standard deviation and. returns to main method.

package com.javaprogramto.programs.arrays.calculation;

public class StandardDeviation {

	public static void main(String[] args) {

		int[] array = { 1, 2, 3, 4, 5, 6, 7, 8, 9 };

		double standardDeviation = calculateStandardDeviation(array);

		System.out.format("Standard deviation : %.6f", standardDeviation);

	}

	private static double calculateStandardDeviation(int[] array) {

		// finding the sum of array values
		double sum = 0.0;

		for (int i = 0; i < array.length; i++) {
			sum += array[i];
		}

		// getting the mean of array.
		double mean = sum / array.length;

		// calculating the standard deviation
		double standardDeviation = 0.0;
		for (int i = 0; i < array.length; i++) {
			standardDeviation += Math.pow(array[i] - mean, 2);

		}

		return Math.sqrt(standardDeviation/array.length);
	}

}
 

Output:

Standard deviation : 2.581989
 

3.  Conclusion

In this article, you've seen how to find the standard deviation in java.

As usual, the shown example is over GitHub.


Java Program to Find the Biggest of 3 Numbers

1. Overview


In this w3schools java programming series, You'll be learning today how to find the biggest of 3 numbers. This is also a very basic interview question. But the interviewer will look for the optimized and fewer lines code. We will show you all the possible programs and how most of java developers think.

For example, given three numbers 4 67 8. Among these three 67 is bigger. For this, we need to perform a comparison with all numbers.

How to add 3 numbers in java?