Assignment - 2(Final)
Assignment - 2(Final)
(AUTONOMOUS)
NAMAKKAL - TRICHY MAIN ROAD, THOTTIAM, TRICHY
DEPARTMENT OF INFORMATION TECHNOLOGY
YEAR / SEM : II/III ACADEMIC YEAR : 2022 - 2023(ODD)
20IT301 - JAVA PROGRAMMING
ASSIGNMENT - II
PROPOSED DATE : 07.11.2022 SUBMISSION DATE : 14.11.2022
Register Blooms
S.No Name of the Student Assignment Topics CO Mapping
Number Level
Problem Statement:
Get the Input string from user and parse it to integer,if it is not a number it will
throw number format exception catch it and print "Entered input is not a valid for
an integer" Or else print the square of that number.
Sample Input and Output 1:
Enter an Integer : 12 CO3 C
1 621321205001 ABINESH A The square value is 144
The work has been done successfully
Sample Input and Output 2:
Enter an Integer: Java
Entered Input is not a valid format for an Integer
Wite a Java Program to demonstrate the different ways of creating thread. CO4 C
Create a simple menu application using Menu class with help of java program. CO5 C
Write a Java Program to demonstrate the Muliple try and multiple catch
CO3 C
statements.
2 621321205002 ANUSHAA T V
CO4 C
Write a Java Program to demonstrate the creation of thread using extends Applet
Write an applet program to handle all mouse events. CO5 Ap
Write a Program that takes an Input the size of the array and the elements in the
array. The Program then asks the user to enter a particular index and prints the
element at that index.
This program may generates Array Index Out of Bounds Exception.
Use Exception handling mechanism to handle this exception. In the catch block,
print the class name of the exception thrown.
Sample Input and Output 1:
Enter the number of elements in the array:
3
Enter the elements in the array:
20
90
4
Enter the index of the array element you want to to access CO3 C
2
3 621321205003 ARUNKUMAR P
The array element at index 2 = 4
The array element successfully accessed
Sample Output
No
To understate and implement the concepts of Obtaining the Thread's State. CO4 C
Mention the real time example for creating Menus with different methods for
CO5 Ap
menu creation.
Write a Java Program to understand nesting of try and catch blocks CO3 C
Write a Java Program with the concepts of I/O Basics and InputStream and Output
14 621321205014 HARIPRASATH S CO4 C
Stream Reader methods
Write a Java program for JScrollPane and JComboBox CO5 C
We define the following terms:
Lexicographical Order, also known as alphabetic or dictionary order, orders
characters as follows:
A substring of a string is a contiguous block of characters in the string. For
example, the substrings of abc are a, b, c, ab, bc, and abc.
Given a string, s, and an integer,k, complete the function so that it finds the
lexicographically smallest and largest substrings of length k.
Function Description
Complete the getSmallestAndLargest function in the editor below.
getSmallestAndLargest has the following parameters:
string s: a string
int k: the length of the substrings to find CO3 C
Returns string: the string ' + "\n" + ' where and are the two substrings
15 621321205016 HARISH VISHNU K Input Format
The first line contains a string denoting s.
The second line contains an integer denoting k.
Sample Input 0
welcometojava
3
Sample Output 0
ava
wel
Write a Java Program for reading console Input and Writing Console Output CO4 C
An analysis of examination results at a school gave the following distribution of
grades for all subjects taken in one year: A - 10, B - 25, C - 45, D - 20. Write a
CO5 Ap
Java program to represent the distribution of each grade in a pie chart,where each
slice of pie differently colored.
Write a program Program with try and catch & finally block CO3 C
16 621321205017 JANANI E CO4 C
Write a Java Program for implementing the concpts of Reading and Writing files
Write an applet program for displaying the Line, Rectangle and Oval. CO5 C
Write a Java Program to demonstrate the chained exception CO3 C
Write a Java Program to demonstrate the PrintWriter Class CO4 C
17 621321205018 JAWAHAR G
Write an applet program for usage of special fonts for text in Graphics
CO5 C
programming.
Write a program to accept name and age of a person from the command prompt
(passed as arguments when you execute the class) and ensure that the age entered
is >=18 and <60.
Display proper error messages. CO3 C
The program must exist gracefully after displaying the error message in case the
18 621321205019 JONA R
arguments passed are not proper. (Hint: Create a user defined exception class for
handling errors).
Illustrate with example of Life cycle of thread. Write a Java Program to implement
CO4 C
the states of thread.
Write an Applet program to demonstrate the concepts of MVC Connection. CO5 C
Write a Java Program to validate student record using Exception Handling CO3 C
CO4 C
19 621321205020 KANNIKA K Write a Java Program to demonstrate the concepts of File Reader and File Writer
List the layout management and write a Java program for any three layout
CO5 Ap
management.
Write a simple program to prevent creation of second object using Exception
CO3 C
Handling
Write a Java Program to implement the file handling concepts:
i) Create a file name called "Abc.txt".
ii) In that abc.txt file you can write the file about the usage of File Handling
Concepts. CO4 C
20 621321205021 KARTHICK RAJA .S.S
iii) After writing the file now you can read the file "abc.txt" and print the number
of characters
present in the file.
Write a Java Programs for the following Swing Components:
1. Button CO5 C
2. Check Box
Given a string, s, and two indices, start and end, print a substring consisting of all
characters in the inclusive range from start to end -1. You'll find the String class'
substring method helpful in completing this challenge.
Input Format
The first line contains a single string denoting s.
The second line contains two space-separated integers denoting the respective
values of start and end.
CO3 C
Output Format
Print the substring in the inclusive range from start to end-1.
21 621321205022 KATHIRVEL T
Sample Input
Helloworld
37
Sample Output
lowo
Write a Java Program to implement the concpts of BufferedInputStream Reader
CO4 C
and BufferedOutputStream Writer
Construct a program for the concpets of Importing images in Applet and
CO5 Ap
Imageicon using Abstract Window Toolkit
You are given a piece of Java code. You have to complete the code by writing
down the handlers for exceptions thrown by the code. The exceptions the code
may throw along with the handler message are listed below:
Division by zero: Print "Invalid division". CO3 Ap
String parsed to a numeric variable : Print "Format mismatch".
22 621321205023 KEERTHANA R Accessing an invalid index in string : Print "Index is invalid".
Accessing an invalid index in array : Print "Array index is invalid".
Write a Java Program for implementing the concepts of Scanner Class CO4 C
Write a Java Programs for the following Swing Components:
1. Scroll Bar CO5 C
2. Radio Buttons
Write a program that accepts 2 integers a and b as input and finds the quotient of
a/b.
This program may generate an Arithmetic Exception. Use exception handling
mechanisms to handle this exception. In the catch block, print the message as
shown in the sample output.
Also illustrate the use of finally block. Print the message “Inside finally block”.
Sample Input and Output 1:
Enter the 2 numbers:
5 CO3 C
2
23 621321205024 KIRUTHIKA K The quotient of 5/2 = 2
Inside finally block
Sample Input and Output 2:
Enter the 2 numbers:
5
0
DivideByZeroException caught
Inside finally block
Write a Java Program to implementing the file handling concepts and demonstrate
CO4 C
the file closing method
Write a simple program using JScrollPane
CO5 C
Write a simple program using JComboBox.
Write a java program that will check whether a given string is palindrome or not CO3 C
Write a Java Program to creating a thread and implementing the following
24 621321205025 MARUTHU PANDIAN A CO4 C
methods : isAlive() and join()
CO5 Ap
Design a Scientific calculator using event–driven programming paradigm of Java
Given two strings, append them together and return the result.However, if
concatenation creates a double-char, then omit one of the chars. If the inputs are
CO3 C
"Java" and "Programming"then the output should be "Java Programming"(The
Output should be in lowercase)
25 621321205026 MATHIYUGAN R Write a Java Program for Interthread Communication CO4 C
Write an Applet program to implement the following concepts
i) Text Box
CO5 C
ii) Label Box
iii) Text Area
Given two strings, append them together and return the result.However, if
concatenation creates a double-char, then omit one of the chars. If the inputs are
CO3 C
"Java" and "Programming"then the output should be "Java Programming"(The
Output should be in uppercase)
26 621321205027 MOHAMMED AFRITH M Write a Java Program to implement the concepts of following methods
i) NORMAL_PRIORITY
CO4 C
ii) MAX_PRIORITY
iii) MIN_PRIORITY
Write a Applet Program to implement various Event handling methods CO5 C
Given two strings, append them together and return the result.However, if
concatenation creates a double-char, then omit one of the chars. If the inputs are
CO3 C
"Java" and "Programming"then the output should be "Java Programming"(The
Output should be in uppercase of First character and last character)
27 621321205028 MUGILAN.S Write a Java Program to implement the concepts of Thread Priorities CO4 C
Wite a Applet program to implement the following: Create four check boxes. The
initial state of the first box should be in checked state. The status of each check
CO5 C
box should be displayed. When we change the state of a check box, the status
should be displayed is updated.
Write java code to implement exception handling. Use of keywords throw, throws,
try, catch, and finally. Checked and unchecked exceptions. Writecode that deals CO3 C
with both checked and unchecked exceptions. Write custom exception classes by
extending base exception classes from the API.Code using try-with-resources
Write a Java program for printing the following patterns in the output screen.
1. Table for 2
28 621321205029 MUKESH RAJAN N
2. Table for 5 CO4 C
3. Table for 100
By using synchronized methods and blocks.
Write a program to create a frame with the following menus, such that the
corresponding geometric object is created when a menu is clicked.
CO5 C
a. Circle. b. Rectangle.
c. Line. d. Diagonal for the rectangle
Given a string, return a new string made of n copies of the first two chars of the
original string where the length of the string. The string may be any length . If
CO3 C
there are fewer than 2 chars, whatever is there.
If input is "Naveen" then output should be "NaNaNaNaNa"
Write a java application program for generating four threads to perform the
following operations:
29 621321205030 NAVEEN J N
i. Getting N numbers as input
CO4 C
ii. Printing the numbers divisible by 5
iii. Printing the even numbers
iv. Computing Average .
Mention the real time example for creating Menus with different methods for
CO5 Ap
menu creation.
Write a Java Program to create custom exception using Exception Handling CO3 C
Write a Java progam that prints the numbers from 1 to 10 line by line after every
CO4 C
10 seconds.
30 621321205031 NIKITHA VARDHINI V Code a java program to implement the following:
Create four check boxes. The initial state of the first box should be in checked
CO5 C
state. The status of each check box should be displayed. When we change the state
of a check box, the status should be displayed is updated.
Two strings, a and b, are called anagrams if they contain all the same characters in
the same frequencies. For this challenge, the test is not case-sensitive. For
example, the anagrams of CAT are CAT, ACT, tac, TCA, aTC, and CtA.
Function Description
Complete the isAnagram function in the editor.
isAnagram has the following parameters:
• string a: the first string
• string b: the second string
Returns
boolean: If and are case-insensitive anagrams, return true. Otherwise, return false.
Input Format
The first line contains a string a. CO3 C
The second line contains a string b.
Sample Input 0
anagram
margana
31 621321205032 NILANI S
Sample Output 0
Anagrams
Sample Input 1
anagramm
marganaa
Sample Output 1
Not Anagrams
Write a java application program for generating four threads to perform the
following operations:
i. Getting N numbers as input
CO4 C
ii. Printing the numbers divisible by 5
iii. Printing the even numbers
iv. Computing Average .
Write a simple Java program for Event Handlers:
1. Keyboard CO5 C
2. Mouse
Given a string of of Odd length, retuns the first half. So the string "Pooja" yields
CO3 C
Poo. If the string length is even number then return null.
32 621321205033 POOJA S
Write a Java Program for suspending, Resuming and Stopping the threads. CO4 C
Write an Applet program to demonstrate the concepts of MVC Connection. CO5 C
Given a string, return a new string made of n copies of the first two chars of the
original string where the length of the string. The string may be any length . If
CO3 C
there are fewer than 2 chars, whatever is there.
If input is "Poornika" then output should be "PooPooPooPooPoo"
Write a Java program for printing the following patterns in the output screen.
33 621321205034 POORNIKA M 1. Table for 2
2. Table for 5 CO4 C
3. Table for 100
By using synchronized methods and blocks.
Write an applet program for usage of special fonts for text in Graphics
CO5 C
programming.
Given a string of of even length, retuns the first half. So the string "Ragavan"
CO3 C
yields Raga. If the string length is Odd number then return null.
Write a Java Program to implement the file handling concepts:
i) Create a file name called "Abc.txt".
ii) In that abc.txt file you can write the file about the usage of File Handling
34 621321205036 RAGAVAN M Concepts. CO4 C
iii) After writing the file now you can read the file "abc.txt" and print the number
of characters
present in the file.
Construct a program for the concpets of Importing images in Applet and
CO5 Ap
Imageicon using Abstract Window Toolkit
Given a string, return a version without the first and last character, so
CO3 C
"Ragavendran" yields "agavendra". The string length will be atleast 2.
CO4 C
Write a Java Program to demonstrate the creation of thread using extends Applet
35 621321205037 RAGAVENDRAN S
Code a java program to implement the following:
Create four check boxes. The initial state of the first box should be in checked
CO5 C
state. The status of each check box should be displayed. When we change the state
of a check box, the status should be displayed is updated.
Given a string, return a version without the first character, so "Rajesh" yields
CO3 C
"ajesh". The string length will be atleast 2.
36 621321205038 RAJESH K S CO4 C
Write a Java Program to demonstrate the concepts of File Reader and File Writer
Write a Java Program and returned by the getGraphics( ) method of Component(all
CO5 C
methods).
Given two strings a and b, return a string of the form short + long + short
with the shorter string on the outside and the longer string on the inside. CO3 C
The strings will not be the same length, but may the empty. If the input
"hi" and "Ramakrishnan", then output will be "hiRamakrishnanhi".
Write a Java Program to implement the file handling concepts:
37 621321205039 RAMAKRISHNAN R i) Create a file name called "Abc.txt".
ii) In that abc.txt file you can write the file about the usage of File Handling
Concepts. CO4 C
iii) After writing the file now you can read the file "abc.txt" and print the number
of characters
present in the file.
Write a Applet Program to implements the methods of working with 2D shapes. CO5 C
Given two strings a and b, return a string of the form short + long + short
with the shorter string on the outside and the longer string on the inside.
CO3 C
The strings will not be the same length, but may the empty. If the input
"hi" and "Ramya" and "Hello, then output will be "hiRamyaHello".
Write a Java Program to implement the concepts of following methods
38 621321205040 RAMYADHARSHINI D
i) NORMAL_PRIORITY
CO4 C
ii) MAX_PRIORITY
iii) MIN_PRIORITY
Write a Applet Program to implements the methods of working with color,font
CO5 C
and images.
Given a string, if the first or last characters are 'x' return the string without those 'x'
character and otherwise return the string unchanged.
Sample Input and Output 1:
Input: xRasidha Begumx
CO3 C
Output: Rasidha Begum
Sample Input and Output 2:
Input: Rasidha Begum
Output: Rasidha Begum
On the first line, print an integer, n, denoting the number of tokens in string s (they
do not need to be unique). Next, print each of the n tokens on a new line in the
same order as they appear in input string s. CO3 C
50 621321205052 SHALINI.S Sample Input:
I am a Java Programmer, why not you?
Sample Output:
8
I
am
a
Java
Programmer
why
not
you
CO4 Ap
Create a Bank database application program to illustrate the use of multithreading.
To create simple AWT program for Java CardLayout CO5 Ap
Given a string, s, and two indices, start and end, print a substring consisting of all
characters in the inclusive range from start to end -1. You'll find the String class'
substring method helpful in completing this challenge.
Input Format
The first line contains a single string denoting s.
The second line contains two space-separated integers denoting the respective
values of start and end.
CO3 C
Output Format
51 621321205053 SHIVAANI M Print the substring in the inclusive range from start to end-1.
Sample Input
Helloworld
37
Sample Output
lowo
Write a java program for banking application to illustrate the usage of thread
CO4 C
synchronized keyword and inter thread communication process.
Write a Java program that copies the content of one file to another using Input and
CO5 C
Output classes.
Type the program above and compile. Run and enter an integer between 1 and 10.
The program is requesting a number between 1 and 10. Run the program again and
enter 5.5. Although this number is between 1 and 10, the program will abort.
Examine the error message. You should see the word Exception, the method
where the exception occurred (main), the class name of the exception
(InputMismatchException), as well as the call stack listing the method calls.
Add a try/catch block to catch and handle the InputMismatchException exception.
Identify the statements that cause the error as well as the portions of the program
that depend upon these statements. Enclose these statements within the try block.
Follow the try block with the catch block given below. Note, the
InputMismatchException class is defined in java.util and must be imported. Also, CO3 C
when the Scanner throws an InputMismatchException, the input token will remain
in the buffer so that it can be examined by the program. In our case, we will not
52 621321205054 SIVA HARISH R be examining the token, but will simply clear out of the buffer to start over.
catch (InputMismatchException ime) {