Monday, July 7, 2014

Java interview programming questions 

Programs – Category A:

  1. Write a program to accept two numbers from the user and find their sum and average.
  2. Write a program to accept a number from the user and find the cube of that number (to the power 3).
  3. Write a program to find the simple interest based on the following data: P = Rs 6000, R = 10%, T = 1.5 years.
  4. Write a program to accept two numbers from the user and swap their values. (Example: x=12, y=15; after swapping x=15, y=12)
  5. Write a program to accept the weight of 5 persons (one by one) and display the net weight and the average weight.
Programs on “If” statement:

  1. Write a program to accept a number from the user. If the number is negative then convert it to a positive number and print; if it is a positive number, print it as is.
  2. Write a program to accept the bill amount and age of the customer; if the customer’s age is >50 years then give a discount of 5% on the bill.
  3. Write a program to accept a number and find whether it is even or odd.
  4. Write a program to accept two numbers from the user and find the bigger of the two.
  5. Write a program to accept three numbers and find the biggest number.
  6. If cost price and selling price of an item is input through the keyboard, write a program to determine whether the seller has made a profit or incurred a loss. Also determine the quantum of profit or loss.
  7. Write a program to accept any character from the user; determine whether it is – a letter in the upper case, lower case, digit, or a special symbol. (Hint: Use ASCII values.)

Programs on “Iterative” statement:
  1. Write a program to accept a number from the user and print its multiplication table (upto “times 10”).
  1. Write a program to accept a number and find the factorial of the number.
  1. Write a program to accept a number,calculate the sum of all even numbers from 0 till the given number; similarly repeat the same for the odd numbers; then display these two sums. (Example: input number 6; sum of even numbers = 0+2+4+6 =12, sum of odd numbers = 1+3+5 = 9)
  1. Write a program to accept a number from the user; display the natural number series for the entered number (1,2,3,4,…,N) and calculate the sum of this series.
  1. Write a program to accept a number and determine whether it is a prime number or not.
  1. Write a program to print the Fibonacci series up to the number 34. (Example: 0,1,1,2,3,5,8,13,…Series starts with 0 and 1, the succeeding numbers of the series are arrived by adding the previous 2 numbers.)
  1. Write a program to accept a number “n” from the user; then display the sum of the series 1+1/2+1/3+……….+1/n.
  1. Write a program to accept a number “n” from the user; then display the series 1,3,5,7,9,…,n and find the sum of the numbers in this series.

  1. Write a program to accept 2 different numbers from the user and print the prime numbers between these 2 numbers.

  1. Write a program to print the following output.
1
2 3
4 5 6 7
8 9 10 11
  1. Write a program to print the following output.
*
* *
* * *
* * * *
* * * * *
  1. Write a program to print the following output.
                         *
                         * * *
                         * * * * *
                         * * * * * * *
                         * * * * * * * * *
  1. Write a program to print the following output.
                             1
                             121
12321
1234321
123454321

  1. Write a program to print the following output.
                    19 0 0
                    0 19 0
                    0 0 19

  1. Write a program to accept a number “n” from the user; find the sum of the series 1/23+1/33+1/43……..+1/n3.


Programs on “Iterative” statement:

  1. Write a program to accept a number from the user and count the number of digits in the number.
  2. Write a program to accept a number from the user and find the sum of digits in the given number.
  1. Write a program to accept a number from the user and find the reverse of the given number.
  1. Write a program to accept a number from the user and determine whether it is an Armstrong number or not (Example : 153 is Armstrong 1^3 + 5 ^3 +3 ^3 =153)
  1. Write a program to accept a number from the user and find the sum of digits of the number; repeat the operation till the sum gets to be a single digit number.
  1. Write a program to accept a number from the user and find the count of the digits that are prime numbers.
  1. Write a program to accept a number and find the factorial of the number (using while loop).
  1. Write a program to accept a four digit number from the user and display its denomination.

Example: 5698
Output: 5*1000 =5000
6*100 =600
9*10 =90
8*1 =8
  1. Write a program to accept a five digit number and increment each digit by one and display the number (digit 9 gets incremented to 0).
Example:
     Input: 14385
Output: 25496


  1. Write a program to accept 2 numbers “m” and “n” from the user and determine m^n (without using predefined functions).

Spring Boot 3 : JWT with SecurityFilterChain, AuthorizeHttpRequests, RequestMatchers

pom.xml <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0"...