0% found this document useful (0 votes)
23 views19 pages

Assignment - 2 For 2024-A

Hvebxyebyxbeyx h exhibition ydb USB j he xhdbxudnxj hbusbuxe ubxydbxuech jb udbcudnc h sbubecux hbeucbrucb hbcurbcud h udb udbc jdn udbc hdn udbc xueb ud ucndu bud. Udb udbc b.
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 views19 pages

Assignment - 2 For 2024-A

Hvebxyebyxbeyx h exhibition ydb USB j he xhdbxudnxj hbusbuxe ubxydbxuech jb udbcudnc h sbubecux hbeucbrucb hbcurbcud h udb udbc jdn udbc hdn udbc xueb ud ucndu bud. Udb udbc b.
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/ 19

PONJESLY COLLEGE OF ENGINEERING

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

CS3391-OBJECT ORIENTED PROGRAMMING

SEM/YEAR: III/II- A

ASSIGNMENT-2

SL.NO. REGISTER NUMBER STUDENT NAME TOPICS


1. 961823104001 AARSSEN G A Write a Java program to create a basic Java thread that
prints "Hello, World!" when executed.

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.

3. 961823104003 ABHISEK R B Write a Java program that sorts an array of integers


using multiple threads.
4. 961823104004 ABINANTHU K Write a Java program that performs matrix
multiplication using multiple threads.

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.

6. 961823104006 ABISHA R Write a Java program to reverse an array of integer


values.

Write a Java program that checks whether an array is


negative dominant or not. If the array is negative
dominant return true otherwise false.
7. 961823104007 ABISHA R Write a Java program that creates a bank account with
concurrent deposits and withdrawals using threads.

8. 961823104008 ABISHA U Write a Java program to create and start multiple


threads that increment a shared counter variable
concurrently.

9. 961823104009 ABISHARATH R S Write a Java program to create a producer-consumer


scenario using the wait() and notify() methods for
thread synchronization.
10. 961823104010 ABISHEK A Write a Java program that uses the ReentrantLock class
to synchronize access to a shared resource among
multiple threads.

11. 961823104011 ABISHEK D P Write a Java program to demonstrate Semaphore usage


for thread synchronization.

12. 961823104012 ABISHEK R T Write a Java program to test if an array contains a


specific value.

Write a Java program to find and print one continuous


subarray that if you only sort the subarray in ascending
order then the entire array will be sorted in ascending
order.

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.

15. 961823104015 ADITHIYAN V N Write a Java program demonstrating how to access a


map concurrently using the ConcurrentHashMap class.

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.

26. 961823104027 ANEEF NIYAZ A


Write a Java program to create a generic method that
takes a list of any type and returns it as a new list with
the elements in reverse order.

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:

Original String = Java Exercises!


The character at position 0 is J
The character at position 10 is i

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:

Original String : w3resource.com


Character(unicode point) = 119
Character(unicode point) = 99

33. 961823104034 ARUN Y L Write a Java program to count Unicode code points in
the specified text range of a string.

Sample Output:

Original String : w3rsource.com


Codepoint count = 9

34. 961823104035 ASHIKA J Write a Java program to compare two strings


lexicographically.
Two strings are lexicographically equal if they are the
same length and contain the same characters in the
same positions.

Sample Output:

String 1: This is Exercise 1


String 2: This is Exercise 2
"This is Exercise 1" is less than "This is Exercise 2"

35. 961823104036 ASHIK V S Write a Java program to compare two strings


lexicographically, ignoring case differences.

Sample Output:

String 1: This is exercise 1


String 2: This is Exercise 1
"This is exercise 1" is equal to "This is Exercise 1"

36. 961823104037 ASHWIN S Write a Java program to concatenate a given string to


the end of another string.

Sample Output:

String 1: PHP Exercises and


String 2: Python Exercises
The concatenated string: PHP Exercises and Python
Exercises

37. 961823104038 ASMITHA I


Write a Java program to test if a given string contains
the specified sequence of char values.

Sample Output:

Original String: PHP Exercises and Python Exercises


Specified sequence of char values: and
true

38. 961823104039 ASMITHA A Write a Java program to compare a given string to the
specified character sequence.

Sample Output:

Comparing example.com and example.com: true


Comparing Example.com and example.com: false

39. 961823104040 ATHEESH R J


Write a Java program to compare a given string to a
specified string buffer.
Sample Output:

Comparing example.com and example.com: true


Comparing Example.com and example.com: false

40. 961823104041 BALAJI S L


Write a Java program to create a String object with a
character array.

Sample Output:

The book contains 234 pages.

41. 961823104042 BALA SUBRAMANIAM M J Write a Java program to check whether a given string
ends with another string.

Sample Output:

"Python Exercises" ends with "se"? false


"Python Exercise" ends with "se"? true

42. 961823104043 BERKLIN JIBITH A Write a Java program to check whether two String
objects contain the same data.

Sample Output:

"Stephen Edwin King" equals "Walter Winchell"? false


"Stephen Edwin King" equals "Mike Royko"? false

43. 961823104044 BEXEL J Write a Java program to compare a given string to


another string, ignoring case considerations.

Sample Output:

"Stephen Edwin King" equals "Walter Winchell"? false


"Stephen Edwin King" equals "stephen edwin king"?
true

44. 961823104045 CHANDRU G L Write a Java program to print the current date and time
in the specified format.

Sample Output:

Current Date and Time :


June 19, 2017
3:13 pm

45. 961823104046 DERIN DANIEL D


Write a Java program to get the contents of a given
string as a byte array.
Sample Output:

The new String equals This is a sample String.

46. 961823104047 DEVA INIYA G Write a Java program to get the contents of a given
string as a character array.

Sample Output:

The char array equals "[C@2a139a55"

47. 961823104048 DIJO ASHIK D Write a Java program to create a distinct identifier for a
given string.

Sample Output:

The hash for Python Exercises. is 863132599

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:

str1 == str2? false


str1 == str3? true

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.

Write a Java program to get a substring of a given


string at two specified positions
53. 961823104054 GOPI SELVAM I Write a Java program to create a character array
containing a string
Write a Java program to convert all characters in a
string to lowercase.
54. 961823104055 GOWTHAM SANKAR S L Write a Java program to convert all characters in a
string to uppercase.

Write a Java program to trim leading or trailing


whitespace from a given string.
55. 961823104056 JACOB S D Write a Java program to find the longest Palindromic
Substring within a string.

Write a Java program to find all interleavings of given


strings.

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.

Write a Java program to find the length of the longest


substring of a given string without repeating characters.

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.

Write a Java program to rearrange a string so that the


same characters are positioned a distance away.

63. Write a Java program to remove "b" and "ac" from a


given string.
Write a Java program to find the first non-repeating
character from a stream of characters.
SAJIN N
64. Write a Java program to find the lexicographic rank of
a given string.
Write a Java program to count and print all duplicates
MADHU MITHA 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
string contains wildcard characters.

HOD
PONJESLY COLLEGE OF ENGINEERING

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

CS3391-OBJECT ORIENTED PROGRAMMING

SEM/YEAR: III/II

ASSIGNMENT-2

SL.NO. REGISTER NUMBER STUDENT NAME TOPICS


1.
Write a Java program to create a basic Java thread that
AAMINA M R prints "Hello, World!" when executed.

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.

ABISHEK SANJAY J Write a Java program that checks whether an array is


negative dominant or not. If the array is negative
dominant return true otherwise false.
961823104006
7.
Write a Java program that creates a bank account with
ABISH KUMAR S concurrent deposits and withdrawals using threads.

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.

AUGNELIN VARSHA L Sample Output:

Original String = Java Exercises!


The character at position 0 is J
The character at position 10 is i
961823104031
31.
Write a Java program to get the character (Unicode
AUSTIN EBINESH U code point) 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.

BALAJI M A Sample Output:

Original String : w3resource.com


Character(unicode point) = 119
Character(unicode point) = 99
961823104033
33.
Write a Java program to count Unicode code points in
the specified text range of a string.

BENITH G Sample Output:

Original String : w3rsource.com


Codepoint count = 9
961823104034
34.
Write a Java program to compare two strings
lexicographically.
Two strings are lexicographically equal if they are the
same length and contain the same characters in the

BENOLIN JOSE M same positions.

Sample Output:

String 1: This is Exercise 1


String 2: This is Exercise 2
"This is Exercise 1" is less than "This is Exercise 2"
961823104035
35.
Write a Java program to compare two strings
lexicographically, ignoring case differences.
BINNY HINN R
Sample Output:

961823104036 String 1: This is exercise 1


String 2: This is Exercise 1
"This is exercise 1" is equal to "This is Exercise 1"

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.

BRIGHTA B Sample Output:

Original String: PHP Exercises and Python Exercises


Specified sequence of char values: and
true
961823104038
38.
Write a Java program to compare a given string to the
specified character sequence.

BRINDHA D S Sample Output:

Comparing example.com and example.com: true


Comparing Example.com and example.com: false
961823104039
39.
Write a Java program to compare a given string to a
specified string buffer.

C JESSICA Sample Output:

Comparing example.com and example.com: true


Comparing Example.com and example.com: false
961823104040
40.
Write a Java program to create a String object with a
character array.

CYRIL ANDERSON J
Sample Output:

The book contains 234 pages.


961823104041
41.
Write a Java program to check whether a given string
DEEBAK SHARON J
ends with another string.
961823104042
Sample Output:

"Python Exercises" ends with "se"? false


"Python Exercise" ends with "se"? true

42.
Write a Java program to check whether two String
objects contain the same data.

DEEBU J Sample Output:

"Stephen Edwin King" equals "Walter Winchell"? false


"Stephen Edwin King" equals "Mike Royko"? false
961823104043
43.
Write a Java program to compare a given string to
another string, ignoring case considerations.

DEVIKA D Sample Output:

"Stephen Edwin King" equals "Walter Winchell"? false


"Stephen Edwin King" equals "stephen edwin king"?
true
961823104044
44.
Write a Java program to print the current date and time
in the specified format.

EMMANUVEL S Sample Output:

Current Date and Time :


June 19, 2017
3:13 pm
961823104045
45.
Write a Java program to get the contents of a given
string as a byte array.

ENBA KINGSLIN J
Sample Output:

The new String equals This is a sample String.


961823104046
46.
Write a Java program to get the contents of a given
string as a character array.

ESTNA SATHEESH
Sample Output:

The char array equals "[C@2a139a55"


961823104047
47.
Write a Java program to create a distinct identifier for a
FINNEY PAUL P
given string.
961823104048
Sample Output:

The hash for Python Exercises. is 863132599

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.

GNANA SHANIKA G Sample Output:

str1 == str2? false


str1 == str3? true
961823104050
50.
Write a Java program to get the length of a given
string.

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

You might also like