0% found this document useful (0 votes)
23 views

Programs to study.docx

Uploaded by

nandu02mohan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views

Programs to study.docx

Uploaded by

nandu02mohan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Programs to study

1. Write a Java program that prompts the user to input two passwords and checks if
they match. The program should provide feedback indicating whether the passwords
are the same or different.
2. Write a Java program to perform the following operations in an array of size ‘N’.
Count the number of elements in an array and also find the maximum and minimum
element in the array.
3. Write a Java program to create an Animal interface with a method called speak() that
takes no arguments and returns void. Create a Dog class that implements Animal and
overrides speak() to print "Dog is barking". Create a Cat class that implements Animal
and overrides speak() to print "Cat is meowing". Create instances of Dog and Cat as
Animal types and invoke the speak() method on each instance to demonstrate
polymorphism.
4. Develop a banking application that includes methods for Deposit, Withdraw, and
CheckBalance. Write a Java program that implements user-defined exceptions to
handle the following scenarios:
● If the user attempts to withdraw an amount exceeds the current
balance, throw an exception called “ExceedException”
● If the user tries to deposit a negative amount, throw an exception called
“NegativeException”
● If the user attempts to check the balance of an account that does not
exist, throw an exception called “AccountException”.
5. Write a java program to input marks of five subjects Physics, Chemistry, Biology,
Mathematics and Computer. Calculate percentage and grade according to following:
a. Percentage >= 90% : Grade A
b. Percentage >= 80% : Grade B
c. Percentage >= 70% : Grade C
d. Percentage >= 60% : Grade D
e. Percentage >= 40% : Grade E
f. Percentage < 40% : Grade F
6. Write a java program to obtain transpose of a 3 x 3 matrix. The transpose of a matrix
is obtained by exchanging the elements of each row with the elements of the
corresponding column.
7. Write a Java application in Java for automating the Banking Operations using
packages. Create an Account class in pkg1, SavingsAccount class, and CurrentAccount
class both of which inherits the Account class in pkg2. Perform menu-driven
operations like Deposit, Withdraw, and Balance Enquiry from a Test class by
importing these two packages.
8. Develop a java program for Shape interface having methods area() and perimeter().
Create two subclasses, Circle and Rectangle that implement the Shape interface.
Write a class Sample with main method and demonstrate the area and perimeters of
both the shape classes. You need to handle the values of length, breath, and radius in
respective classes to calculate their area and perimeter.
9. Write a Java program using ArrayList.
a. Create a ArrayList to hold the product names of data type String.
b. Add five different product names.
c. Print the first and last product names.
d. Print the size of the ArrayList.
e. Remove a particular product from ArrayList.
f. Replace the existing element with new element in the ArrayList.
10. Write a Java program to create a text file, write new content into it, and then read
and print the content using appropriate reader and writer classes.
11. Write a Java program to demonstrate TCP-IP connection oriented one-way chat using
java networking model.
12. Write a java program by implementing a Thread class with a run() method that
converts all lowercase characters in a given string to its equivalent uppercase
character.
13. Write a Java program to design a class for “Smartphone” with model name, year, cost
as data members. Include constructors and setter/getter methods. Add another class
“Main” which creates two objects, initialize the data members and display the details
through getter methods.
14. Write a Java program using ArrayList.
● Create an ArrayList to store product names of type String.
● Add two product names to the ArrayList.
● Print the size of the ArrayList.
● Replace an existing element in the ArrayList with a new product name.
15. Write a Java program to create and start a thread using the Thread class. Implement
a run() method that prints numbers from 1 to 10 with a delay of 1000 milliseconds
between each number.
16. Write a Java program that safely copies the contents from source.txt to
destination.txt.
17. Write a Java program using the generic Stack collection to manage a to-do list
application. The program should allow the user to add tasks (as strings) to the stack,
remove the most recent task, and display all tasks in the stack.
18. Write a Java program that establishes a simple client-server communication

You might also like