Assignment - 2 For 2024-A
Assignment - 2 For 2024-A
SEM/YEAR: III/II- A
ASSIGNMENT-2
2. 961823104002 AATHISH G P Write a Java program that creates two threads to find
and print even and odd numbers from 1 to 20.
5. 961823104005 ABIRAMI S C Write a Java program that calculates the sum of all
prime numbers up to a given limit using multiple
threads.
13. 961823104013 ACHAULIN JUAN B Write a Java program that uses the CountDownLatch
class to synchronize the start and finish of multiple
threads.
14. 961823104014 ADHI LEXMAN N Write a Java program to illustrate the usage of the
ReadWriteLock interface for concurrent read-write
access to a shared resource.
16. 961823104016 ADONI JONES C B Write a Java program that utilizes the
ConcurrentLinkedQueue class to implement a thread-
safe queue.
17. 961823104017 AHILAN E Write a Java program to showcase the usage of the
Phaser class for coordination and synchronization of
multiple threads.
18. 961823104018 AISHWARYA S Write a Java program that utilizes the Exchanger class
for exchanging data between two threads.
19. 961823104020 AJESH K R Write a Java program to demonstrate the usage of the
Callable and Future interfaces for executing tasks
asynchronously and obtaining their results.
20. 961823104021 AJISHA D Write a Java program that uses the
ScheduledExecutorService interface to schedule tasks
for execution at a specified time or with a fixed delay
21. 961823104022 AJU B Write a Java program to demonstrate the usage of the
ForkJoinPool class for parallel execution of recursive
tasks.
22. 961823104023 AKASH R Write a Java program that utilizes the StampedLock
class for optimizing concurrent read-write access to a
shared resource.
23. 961823104024 AKSHATH S Write a Java program to create a generic method that
takes two arrays of the same type and checks if they
have the same elements in the same order.
24. 961823104025 ALDRIN AJAY S Write a Java program to create a generic method that
takes a list of numbers and returns the sum of all the
even and odd numbers.
25. 961823104026 ANCELIN S Write a Java program to create a generic method that
takes a list of any type and a target element. It returns
the index of the first occurrence of the target element in
the list. Return -1 if the target element cannot be found.
27. 961823104028 ANTO J Write a Java program to create a generic method that
takes two lists of the same type and merges them into a
single list. This method alternates the elements of each
list.
28. 961823104029 ANTO PRIYANKA X J . Write a Java program to create a generic method that
takes a list of any type and a predicate. It returns an
array list containing only elements that satisfy the
predicate.
29. 961823104030 ANUGRAGHA S S Write a Java program to create a generic method that
takes a map of any type and prints each key-value pair.
30. 961823104031 ANUTHERSH V Write a Java program to get the character at the given
index within the string.
Sample Output:
31. 961823104032 ARI JOTHIESH R Write a Java program to get the character (Unicode
code point) at the given index within the string.
32. 961823104033 ARSHI FATHIMA M N Write a Java program to get the character (Unicode
code point) before the specified index within the string.
Sample Output:
33. 961823104034 ARUN Y L Write a Java program to count Unicode code points in
the specified text range of a string.
Sample Output:
Sample Output:
Sample Output:
Sample Output:
Sample Output:
38. 961823104039 ASMITHA A Write a Java program to compare a given string to the
specified character sequence.
Sample Output:
Sample Output:
41. 961823104042 BALA SUBRAMANIAM M J Write a Java program to check whether a given string
ends with another string.
Sample Output:
42. 961823104043 BERKLIN JIBITH A Write a Java program to check whether two String
objects contain the same data.
Sample Output:
Sample Output:
44. 961823104045 CHANDRU G L Write a Java program to print the current date and time
in the specified format.
Sample Output:
46. 961823104047 DEVA INIYA G Write a Java program to get the contents of a given
string as a character array.
Sample Output:
47. 961823104048 DIJO ASHIK D Write a Java program to create a distinct identifier for a
given string.
Sample Output:
48. 961823104049 DURGA L Write a Java program to get the index of all the
characters of the alphabet.
Sample Output:
a bc de f ghi j
=========================
36 10 7 40 2 16 42 1 6 20
k l m n o pq r s t
===========================
8 35 22 14 12 23 4 11 24 31
u v w x y z
================
5 27 13 18 38 37
Sample string of all alphabet: "The quick brown fox
jumps over the lazy dog."
49. 961823104050 EMIL PRATHAP SINGH J Write a Java program to get the Canonical
representation of the string object.
Sample Output:
50. 961823104051 EMISTON M Write a Java program to get the length of a given
string.
Write a Java program to find out whether a region in
the current string matches a region in another string.
51. 961823104052 FATHIMA NAJIYA Write a Java program to replace a specified character
with another character
Write a Java program to replace each substring of a
given string that matches the given regular expression
with the given replacement.
52. 961823104053 GODLIN BEJOL E L Write a Java program to check whether a given string
starts with another string.
56. 961823104057 JASBIN PABI P J Write a Java program to find the second most frequent
character in a given string.
Write a Java program to print all permutations of a
given string with repetition
57. 961823104058 JASHIYA DENIT J Write a Java program to check whether two strings
interlive of a given string. Assuming that unique
characters are present in both strings.
58. 961823104059 JASHWANTH RIYASH C Write a Java program to print the result of removing
duplicates from a given string.
Write a Java program to find the first non-repeating
character in a string.
59. 961823104060 JATHESH M P Write a Java program to divide a string into n equal
parts.
Write a Java program to remove duplicate characters
from a given string that appear in another given string.
60. 961823104061 JAYA J DHINEESH Write a Java program to print a list of items containing
all characters of a given word.
Write a Java program to find the character in a string
that occurs the most frequently
61. 961823104062 JEFFRY F J Write a Java program to reverse a string using
recursion.
Write a Java program to reverse words in a given
string.
62. 961823104063 JENIFER J J Write a Java program to reverse every word in a string
using methods.
HOD
PONJESLY COLLEGE OF ENGINEERING
SEM/YEAR: III/II
ASSIGNMENT-2
961823104001
2.
Write a Java program that creates two threads to find
ABINESH M and print even and odd numbers from 1 to 20.
961823104002
3. Write a Java program that sorts an array of integers
ABINESH R A
961823104003 using multiple threads.
4.
Write a Java program that performs matrix
ABISHA B multiplication using multiple threads.
961823104004
5.
Write a Java program that calculates the sum of all
prime numbers up to a given limit using multiple
ABISHA K
threads.
961823104005
6.
Write a Java program to reverse an array of integer
values.
961823104007
8.
Write a Java program to create and start multiple
threads that increment a shared counter variable
ABITHA S
concurrently.
961823104008
9.
Write a Java program to create a producer-consumer
scenario using the wait() and notify() methods for
ADHUL U KRISHNA
thread synchronization.
961823104009
10.
Write a Java program that uses the ReentrantLock class
to synchronize access to a shared resource among
AHINA V
multiple threads.
961823104010
11.
Write a Java program to demonstrate Semaphore usage
AJIN JT for thread synchronization.
961823104011
12.
Write a Java program to test if an array contains a
specific value.
AJIN M
Write a Java program to find and print one continuous
961823104012 subarray that if you only sort the subarray in ascending
order then the entire array will be sorted in ascending
order.
13.
Write a Java program that uses the CountDownLatch
class to synchronize the start and finish of multiple
AKASH G
threads.
961823104013
14.
Write a Java program to illustrate the usage of the
ReadWriteLock interface for concurrent read-write
AKASH JILL CHRIST
access to a shared resource.
961823104014
15.
Write a Java program demonstrating how to access a
AKILESH SIVA N map concurrently using the ConcurrentHashMap class.
961823104015
16.
Write a Java program that utilizes the
ConcurrentLinkedQueue class to implement a thread-
AKSHAYA VS
safe queue.
961823104016
17.
Write a Java program to showcase the usage of the
Phaser class for coordination and synchronization of
ALLWIN E K
multiple threads.
961823104018
18.
Write a Java program that utilizes the Exchanger class
AMIRIS ROSHAN V for exchanging data between two threads.
961823104019
19. Write a Java program to demonstrate the usage of the
AMRISHA E Callable and Future interfaces for executing tasks
961823104020 asynchronously and obtaining their results.
20. Write a Java program that uses the
ANTO JAMILAN A ScheduledExecutorService interface to schedule tasks
961823104021 for execution at a specified time or with a fixed delay
21.
Write a Java program to demonstrate the usage of the
ForkJoinPool class for parallel execution of recursive
APSINE SHYNU S
tasks.
961823104023
22.
Write a Java program that utilizes the StampedLock
class for optimizing concurrent read-write access to a
ARTHI S P
shared resource.
961823104023
23.
Write a Java program to create a generic method that
takes two arrays of the same type and checks if they
ASHIKA E
have the same elements in the same order.
961823104024
24.
Write a Java program to create a generic method that
takes a list of numbers and returns the sum of all the
ASHLIN SHINU D
even and odd numbers.
961823104025
25.
Write a Java program to create a generic method that
takes a list of any type and a target element. It returns
ASHLY S CROSSLIN the index of the first occurrence of the target element in
the list. Return -1 if the target element cannot be found.
961823104026
26.
Write a Java program to create a generic method that
takes a list of any type and returns it as a new list with
ASHMIJA M J
the elements in reverse order.
961823104027
27.
Write a Java program to create a generic method that
takes two lists of the same type and merges them into a
ASLIN SONIA S single list. This method alternates the elements of each
list.
961823104028
28.
. Write a Java program to create a generic method that
takes a list of any type and a predicate. It returns an
ASRIJA A array list containing only elements that satisfy the
predicate.
961823104029
29.
Write a Java program to create a generic method that
ASWINTH S takes a map of any type and prints each key-value pair.
961823104030
30.
Write a Java program to get the character at the given
index within the string.
961823104032
32.
Write a Java program to get the character (Unicode
code point) before the specified index within the string.
Sample Output:
36.
Write a Java program to concatenate a given string to
the end of another string.
Sample Output:
BISMI SUBINA S
String 1: PHP Exercises and
String 2: Python Exercises
The concatenated string: PHP Exercises and Python
Exercises
961823104037
37.
Write a Java program to test if a given string contains
the specified sequence of char values.
CYRIL ANDERSON J
Sample Output:
42.
Write a Java program to check whether two String
objects contain the same data.
ENBA KINGSLIN J
Sample Output:
ESTNA SATHEESH
Sample Output:
48.
Write a Java program to get the index of all the
characters of the alphabet.
Sample Output:
a bc de f ghi j
=========================
36 10 7 40 2 16 42 1 6 20
GANASYAM R S k l m n o pq r s t
===========================
8 35 23 14 12 23 4 11 24 31
u v w x y z
================
5 27 13 18 38 37
Sample string of all alphabet: "The quick brown fox
jumps over the lazy dog."
961823104049
49.
Write a Java program to get the Canonical
representation of the string object.
GOPI S
Write a Java program to find out whether a region in
the current string matches a region in another string.
961823104051
51. Write a Java program to replace a specified character
with another character
Write a Java program to replace each substring of a
GOWSICK M given string that matches the given regular expression
with the given replacement.
961823104052
52.
Write a Java program to check whether a given string
GOWTHAM R S
starts with another string.
961823104053
Write a Java program to get a substring of a given
string at two specified positions
53. Write a Java program to create a character array
containing a string
HARI KUMARI S
Write a Java program to convert all characters in a
961823104054 string to lowercase.
54.
Write a Java program to convert all characters in a
string to uppercase.
HARISH K
Write a Java program to trim leading or trailing
961823104055 whitespace from a given string.
55.
Write a Java program to find the longest Palindromic
Substring within a string.
HARISH L M
Write a Java program to find all interleavings of given
strings.
961823104056
56. Write a Java program to find the second most frequent
character in a given string.
INDHU
Write a Java program to print all permutations of a
961823104058 given string with repetition
57.
Write a Java program to check whether two strings
interlive of a given string. Assuming that unique
characters are present in both strings.
INDIRANI
Write a Java program to find the length of the longest
substring of a given string without repeating characters.
961823104059
58. Write a Java program to print the result of removing
duplicates from a given string.
Write a Java program to find the first non-repeating
JACKULINE
character in a string.
961823104060
59. Write a Java program to divide a string into n equal
parts.
Write a Java program to remove duplicate characters
JARSHIN J S
from a given string that appear in another given string.
961823104061
60. Write a Java program to print a list of items containing
all characters of a given word.
JASEL RESPIN R
Write a Java program to find the character in a string
961823104062 that occurs the most frequently
61. Write a Java program to reverse a string using
JEBIN R
961823104063 recursion.
Write a Java program to reverse words in a given
string.
62.
Write a Java program to reverse every word in a string
using methods.
AJAY V S
Write a Java program to rearrange a string so that the
same characters are positioned a distance away.
961823104301
63. Write a Java program to remove "b" and "ac" from a
given string.
Write a Java program to find the first non-repeating
ATHITH E
character from a stream of characters.
961823104302
64. Write a Java program to find the lexicographic rank of
a given string.
BIJO MOHAN
Write a Java program to count and print all duplicates
961823104303 in the input string.
65. Write a Java program to check if two given strings are
rotations of each other.
Write a Java program to match two strings where one
AFARIN JENICSHA
string contains wildcard characters.
961823104701
HOD