Core Java Assignments

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

Java Program Assignments

1. WAP to reverse a given number


2. WAP to check whether the given number is Armstrong or not. If the number is
Armstrong find the sum of digits of the given number else find the product of digits.
3. WAP to find sum of digits of a given number until the sum of digits is single digit
4. WAP to display the given number in Words (eg: 245 => Two Four Five)
5. WAP to reverse every word of the given line of text
Eg:
Given Line of Text : Java is Simple
Output : avaJ si elpmiS

6. WAP to display Palindromes and count number of Palindromes in the given line of
text

Eg:

Given Line of Text: My madam name is liril

Output

Palindromes : madam, liril

No of palindromes : 2

Exceptions

1. Write a program to calculate area of a rectangle and area of a square by using


method overloading. Take the input for dimension of rectangle and square from
Command Line. Handle appropriate exception in order to stop abnormal
termination of execution
2. Demonstrate that a derived-class constructor cannot catch exceptions thrown by
its base-class constructor
3. Write a program which generates ArrayIndexOutOfBoundsException.
4. Write a program which generates ArithmeticException
5. Write a program which generates NullPointerException
6. Write a program which generates NumberFormatException

Multithreading

1. Write a program which demonstrates join() of Thread class


2. Write a program to find sum of even numbers and sum of odd numbers from 1 to
100 using threads
3. Write a program which displays the following output using Interthread
communication
PUT : 1
GOT : 1
PUT : 2
GOT : 2

….
PUT : 10
GOT : 10

Collections

1. Write a program which do the following stack operations


1. PUSH
2. POP
3. DISPLAY
4. PEEK
5. EXIT
2. Create a Java program which read n number of integers using scanner class until the
given number is zero. Store all these integers into ArrayList which can accept only
integers. Find the average of the elements present in the ArrayList.
3. Write program which do the following linked list operations
1. Add element at First
2. Add element at Last
3. Add element at given position
4. Remove First element
5. Remove last element
6. Update element at given position
7. Display elements
8. Exit
4. Write a program to create an Employee class with attributes empNum, empName
and empSalary.
Create a class EmployeeList which stores the Employee objects. Display the
Employee records in the sorted order of their salaries.
5. Write a program which adds the contact details like name and contact number.
Display the contact details in the sorted order of their name.
IO

Write a program which stores a Student class object into a file “Student.dat” using
serialization.

1. Write a program which reads an Student class object from the file
“Student.dat” using serialization
2. Write a program to store 5 item records (item number, item name, item
quantity and item rate) into a data file “Item.txt” using DataOutputStream.
3. Write a program to reads 5 item records ( item number, item name, item
quantity and item rate) from the data file “Item.txt” using DataInputStream.
Display the output in the following format
S.No Item No Item Name Quantity Rate Price
-------------------------------------------------------------------
1 111 Monitor 5 5000 25000
2 222 Mouse 10 200 2000
3 333 Keyboard 7 200 1400
4 444 Pendrive 5 600 3000
5 555 UPS 4 1000 4000
-------------------------------------------------------------------
Total Price : 35400
--------------------------------------------------------------------

JDBC

1. Create the following Users table in oracle


Username Password
aaa aaa
bbb bbb
ccc ccc
Write a Jdbc program which reads username and password from keyboard and
checks whether the user is authenticated or not. If the user is authenticated display
message “Login Successful” else display “Login Not Successful”

2. Create the following Account table in MySQL with the following columns

AccountNo int(3), AccountType Varchar(10), AccountBalance int(6)

Write a JDBC program which displays the following menu options


1. Insert Record in Account Table
2. Update Record in Account Table by accepting AccountNo
3. Delete Record in Account Table by accepting AccountNo
4. Display Records of Account Table
5. Exit
The menu should get displayed until the user chooses Exit

You might also like