You are on page 1of 62

JAVA PROGRAMMING LAB

Faculty name- Dr.Vinay Kumar Saini Students name - Samarth Malik


Roll no.- 09614803119
Semester – 5TH
Group – I5

Maharaja Agrasen Institute of Technology


Sector-22, Rohini, New Delhi – 110085
INDEX
AIM
LAB - 1
1. Input two numbers from User and print their sum.
2. Input a number from user and check if palindrome is possible by shuffling digits of the
number print yes or No as output.
3. Input two numbers from user lower Limit and upper Limit and print numbers within the
range that have digits in strict increasing order.
4. Generate three random numbers up to 100 and print the largest of them.
5. Generate a random number up to 100 and print whether it is prime or not.
6. Write a program to generate first 10 terms of Fibonacci series.
7. Create java application for Lucky 7 Game.

LAB - 2
8. Find the factorial of a given number using Recursion.
9. Find the average and sum of array of N numbers entered by user.
10. Create a class to find out the Area and perimeter of rectangle.
11. Write a class that perform String operations(Equal,Reverse the string,change case).
12. Given an integer array, find the number of decreasing sequences in the array and the
length of its longest decreasing sequence.
13. Write a program for sorting integer array using selection sort.
14. Demonstrate the use of final keyword with data member, function and class.

LAB - 3
15. Demonstrate the use of keywords try, catch, finally, throw and throws.
16. Write a program to demonstrate Multi-threading using Thread Class.
17. Write a program to demonstrate Multi-threading using Runnable Interface.
18. Write a program to demonstrate use of synchronized block over multi-threading.
19. Write a program to demonstrate use of synchronized method over multi-threading.
20. Write a program to demonstrate static synchronization over multi-threading.
21. Write a program to create game "Tic Tac Toe".
LAB - 4

22. Write a program to print the nth FIBONACCI.


23. Write a program to create PIN from three integer input values.
24. Write a program that returns 2nd word of the input string in upper case.
25. Write a program to check if the given string is a palindrome.
26. Write a program that returns weight of input string.
27. Write a program to returns the most frequent digit in an array.
28. Write a program to returns the string code.
OUTPUT -
OUTPUT -
OUTPUT -
OUTPUT -
OUTPUT -
OUTPUT -
OUTPUT -
OUTPUT -

-
OUTPUT -
OUTPUT -
OUTPUT -
OUTPUT -

-
OUTPUT -

-
OUTPUT -

1.

cannot assign a value to final variable AGE

AGE = 45;

2.

display() in Main cannot override display() in FinalDemo

public final void display() {

overridden method is final

3.

cannot inherit from final FinalClass

class Main extends FinalClass {


OUTPUT -

(i)

(ii)
OUTPUT -
OUTPUT -
OUTPUT -
OUTPUT -
OUTPUT -
OUTPUT -
OUTPUT -
OUTPUT -
OUTPUT -
OUTPUT -
OUTPUT -
OUTPUT -

You might also like