FE SemII - Experiment List 23-24
FE SemII - Experiment List 23-24
A
CB
FED
JIHG
2. To implement Arrays
a. You have been given an array of positive integers A1, A2,...,An with length N and you have to
print an array of same length (N) where the values in the new array are the sum of every number
in the array, except the number at that index.
i/p 1 2 3 4
For the 0th index, the result will be 2+3+4= 9, similarly for the second, third and fourth index
the corresponding results will be 8, 7 and 6 respectively.
i/p 4 5 6
o/p 11 10 9
3. To implement Strings
a. WAP to find out number of uppercase & lowercase characters, blank spaces and digits from
the string.
b. WAP to count the frequency of occurrence of a given character in a given line of text.
c. WAP to check if a string is a palindrome or not using inbuild functions.
5. To implement class with members and methods (static, non-static, recursive and overloaded
methods)
a. Create a class employee with data member’s empid, empname, designation and salary. Write
methods getemployee() to take user input, showgrade() to display grade of employee based on
salary, showemployee() to display details of employee.
b. WAP to display area of square and rectangle using the concept of overloaded functions.
c. WAP to find value of y using recursive function (static), where y=x^n
d. WAP to count the number of objects made of a particular class using static variable and static
method and display the same.
12. To implement exceptions in Java (read input using DataInputStream/ BufferedReader classes)
a. WAP to implement inbuild exceptions
i. Checked exceptions (compile time exceptions)
a. ClassNotFoundException
b. IOException
ii. Unchecked exceptions (run time exceptions)
a. NumberFormatException
b. ArithmeticException
c. ArrayIndexOutOfBounds
d. NullPointerException
b. Write a Java Program to Create a User Defined Exception class MarksOutOfBoundsException,
If Entered marks of any subject is greater than 100 or less than 0, and then program should
create a user defined Exception of type MarksOutOfBoundsException and must have a
provision to handle it.
13. To implement Multithreading
a. Write a multithreaded program a java program to print Table of Five, Seven and Thirteen using
Multithreading (Use Thread class for the implementation).
b. Write a multithreaded program to display /*/*/*/*/*/*/*/* using 2 child threads.
c. Write a program to demonstrate thread methods: wait notify suspend resume join setpriority
getpriority setname getname
d. Write a multithreaded program that generates the Fibonacci sequence. This program should
work as follows: create a class Input that reads the number of Fibonacci numbers that the
program is to generate. The class will then create a separate thread that will generate the
Fibonacci numbers, placing the sequence in an array. When the thread finishes execution, the
parent thread (Input class) will output the sequence generated by the child thread. Because the
parent thread cannot begin outputting the Fibonacci sequence until the child thread finishes,
the parent thread will have to wait for the child thread to finish.
e. WAP to prevent concurrent booking of a ticket using the concept of thread synchronization.