22CM11S1
22CM11S1
LIST OF PROGRAMS:
(Any 12 programs from the following to be performed)
1. Implement the following programs using command line arguments
a) Accept two strings from the user and print it on console with concatenation of “and” in
the middle of the strings.
b) Accept 12-hour time zone and convert into its corresponding 24-hour time zone.
Note: Accept hours, minutes and seconds separately from the user (e.g. 07 05 45 PM
should be displayed as 19:05:45).
2. a) Write a program that accepts an array of integers and print those which are both odd and
prime. If no such element in that array print “Not found”.
b)Write a program that accepts an “m x n” double dimension array, where “m” represents
financial years and “n” represents Ids of the items sold. Each element in the array represents
the number of items sold in a particular year. Identify the year and id of the item which has
more demand.
3. a) Create a class Box that uses a parameterized constructor to initialize the dimensions of a
box. The dimensions of the Box are width, height, depth. The class should have a method
that can return the volume of the box. Create an object of the Box class and test the
functionality.
b) Create a new class called Calculator with the following methods:
● A static method called powerInt (int num1, int num2) This method should return num1 to
the power num2.
● A static method called powerDouble (double num1,double num2). This method should
return num1 to the power num2.
● Invoke both the methods and test the functionality. Also count the number of objects
created.
4. a) Accept an array of strings and display the number of vowels and consonants occurred in
each string.
b) Accept two strings from the user and determine if the strings are anagrams or not.
`
5. a)Create a multilevel inheritance for classes, vehicle, brand and cost. The vehicle class
determines the type of vehicle which is inherited by the class brand which determines the
brand of the vehicle. Brand class is inherited by cost class, which tells about the cost of the
vehicle. Create another class which calls the constructor of cost class and method that displays
the total vehicle information from the attributes available in the super classes.
b) Create an inheritance hierarchy of Figure_3D, Cylinder, Cone, Sphere etc. In the base class
and provide methods that are common to all Figure_3Ds and override these in the derived
classes to perform different behaviors, depending on the specific type of Figure_3D. Create
an array of Figure_3D, fill it with different specific types of Figure_3Ds and call your base
class methods.
6. a) Design a package to contain the class Student that contains data members such as name, roll
number and another package contains the interface Sports which contains some sports
information. Import these two packages in a package called Report which process both Student
and Sport and give the report.
b) Write a program that accepts values of different data types and convert them to corresponding
wrapper classes and display using the vector
7. a) Write a program to generate a set of random numbers between two numbers x1 and x2, and
x1>0.
b) Write a program to implement a new ArrayList class. It should contain add(), get(), remove(),
size() methods. Use dynamic array logic.
8. Create an employee class containing at least 3 details along with Id, setters and getters. Insert the
employee objects dynamically key as employee id and value as its corresponding object into a
HashMap. Perform Id based search operation on the HashMap.
9. Write a program that reads file name from the user then displays information about that file,
also read the contents from the file in byte stream to count number of alphabets, numeric values and
special symbols. Write these statistics into another file using byte streams.
10. a) Write a program that reads two numbers from the user to perform integer division into
Num1 and Num2 variables. The division of Num1 and Num2 is displayed if they are integers. If
Num1 or Num2 were not an integer, the program would throw a Number Format Exception. If
Num2 were Zero, the program would throw an ArithmeticException.
b) Create a user defined exception.
11. a) Write a program that creates 3 threads by extending the Thread class. First thread displays
“Good Morning” every 1 sec, the second thread displays “Hello” every 2 seconds and the third
displays Welcome” every 3 seconds. (Repeat the same by implementing Runnable).
b) Write a program to illustrate Thread synchronization.
`
12. a) Create a JApplet that displays a message which is scrolling from left to right and vice versa.
b) Write a program that displays a sample registration page using Swing controls use appropriate
layout managers.
c) Write a program for handling mouse events with adapter classes.
13. a) Create an interface containing 3 radio buttons named line, rectangle and oval. Based on the
radio button selected, allow user to draw lines, rectangles or ovals as per the locations selected by
the user.
b) Create an interface that illustrates JFileChooser class and read CSV file containing employee data
of various departments and display the records department wise on the interface.
14. For program check all the fields filled or not, display success dialogue if all fields are filled
with the help of ActionListener. Display respective error dialogue if a field is empty.
15. Write a program to create three JSliders where each represents colors RED, GREEN and BLUE.
Each slider has a value from 0 to 255. The background color of the applet is set based on the values
retrieved from each slider to form a color using the color class constructor. On sliding any slider, the
background color of applet changes.
16. Write a program that implements a simple client/server application. The client sends data to a
server. The server receives the data, uses it to produce a result, and then sends the result back to the
client. The client displays the result on the console. For ex: The data sent from the client is the radius
of a circle, and the result produced by the server is the area of the circle.
Case Studies:
● Grading a Multiple-choice Test for students
● Create a Person class containing basic details like Name, Gender, Mobile and Email. Based on
that create and manage the objects that are related to student and employee Classes
● Create a package called Banking containing classes and interfaces related to various banking
operations such as withdrawal, deposits, loans and insurance etc. Create two classes related to any
two specific banks that uses this package.
● Write a program that works as a simple calculator. Use a grid layout to arrange buttons for the
digits and for the+, - ,*, % operations. Add a text field to display the result.
TEXT BOOKS:
1. Herbert Schildt, “Java The Complete Reference”, 11th Edition, McGrawHill, 2019
REFERENCE BOOKS:
1. Y. Daniel Liang “Introduction to Java Programming Comprehensive Version” 10th Edition,
Pearson, 2015