Home‎ > ‎Applied Core Java‎ > ‎


Java Basic Lab Assignments


      1.     Find Maximum of 2 numbers.

2.      Find the smallest of two numbers. using conditional operator.

3.     Write a program that will read a float type value from the   keyboard and print the following output.

a. Smallest integer value which is not less than the number i.e. the whole no nearest to the given number

b. The Number itself.

c. Largest Integer not greater than the number.

4.     Write a program to generate 5 Random nos. between 1 to 100, and it  should not follow with decimal point.

5.     Write a program to find SUM AND PRODUCT of a given Digit.

6.     Write a program to Find Factorial of given no.

7.     Write a program to reverse a given number.

8.     Write a program to find Fibonacci series of a given number.

9.     Write a program to find sum of all integers greater than 100 and less than 200 that are divisible by 7

10.  Write a program to concatenate  string using for loop
 Example: Input – 5 Output - 1 2 3 4 5

11.  Program to create and display 2 dimensional array that contains tables from 2-10 ( 9 Rows, 10 Columns).

12.  Write a program to swap the values, with and without using temporary variables.

13.  Write a program to convert given number of days into months and days.  (Assume that each month is of 30 days)

Example: Input - 69 Output - 69 days = 2 Month and 9 days

14.  Write a program to generate a Triangle.



  2 2

  3 3 3

  4 4 4 4

 and so on as per user given number .

15.   Write a program to Display Invert Triangle.


          Input - 5

          Output :

          5 5 5 5 5

          4 4 4 4

          3 3 3

          2 2


16.  Write a program to find whether given number is Armstrong or not.

  Example :

           Input - 153

           Output - 1^3 + 5^3 + 3^3 = 153, so it is Armstrong no.

17.  Write a program to Find whether number is Prime or Not.

18.  Write a program to find whether no. is palindrome or not.

   Example :

           Input - 12521 is a palindrome no.

           Input - 12345 is not a palindrome no. */

19.  switch case demo

   Example :

           Input - 124

           Output - One Two Four

20.   Write a program to generate Harmonic Series.

   Example :

           Input - 5

           Output - 1 + 1/2 + 1/3 + 1/4 + 1/5 = 2.28 (Approximately)

21.  Write a program to find average of consecutive N Odd number. and Even number.

22.  Reverse an array

This version of reverse uses two subscripts: one that starts at the left (beginning) of the array, and one that starts at the right (end) of the array. You can also use a for loop that goes to the middle of the array.

23.  Write a function that take an integer array as an input and finds the largest number in the Array.

24.  Write a function on that takes an integer array as an input and finds the second largest number in the array?(using single loop, with out sorting array).

25.  Write a program to delete a node from the linked list. (Program construct must use your implementation of linked list).

26.  Two integer array A and B has n elements and  n-1 elements respectively. A has all the elements that are in B, but B has one missing element. Write a function that takes arrays A and B as input and finds the  missing element in the most optimized manner.

27.  You have an array of positive integer arranged in the descending order. Write a function that takes ‘an integer’ and ‘an integer array’ as an input and return the position of the given integer in the array, if the integer is not presenting the integer is not the array it should return -1. The searching Technique that you use should be very efficient both in term of the time it takes and the memory it uses.         

     <<Previous | Next>>

Prachi Pacharne,
Oct 16, 2015, 6:55 AM