You are on page 1of 38

Problem Statement: WAP in java to simulate condition to generate Wi-Fi password.

Take input as Name,


City, Age and Gender.
Constraints: Length of name and city should be greater or equal to 3 and age can’t be 18.
Output Constraints:
1. If Gender=F and Age<18: Password: 1st 3 char of name + sum of digit of age + last 3 char of city
2. Else If gender=F and Age>18: Password: last 3 char of Name + Diff of digit of age (Positive) + 1 st 3 char of
City.
3. Else: Password: 1st char of name + 1st char of city + 2nd char of name + 2nd char of city …
Append this to length of max string (name or city) and then concatenate it with Age to get password.
Objective: Create a Java program that simulates a Wi-Fi password generator based on user input parameters,
adhering to specific constraints and generating passwords according to gender and age rules.

Source Code:
Output:
Problem Statement: WAP in Java to initialize a string to find that character which frequency is 2nd most in
that string.

Objective: Implement a Java program that employs hash maps to identify the character with the second most
frequent occurrence in given string. The program efficiently analyzes character frequencies, prioritizes first
occurrences, and handles empty or invalid input strings.

Source Code:
Output:

1.

Problem Statement: WAP to check longest sub sequence of a same character in an initialized string?
[aaaabppppp, p=5] [aabbcc, a=2].
Objective: Implement a Java program to find the length of the longest consecutive subsequence of identical
characters in a given string.

Source Code:

Output:

1.

Problem Statement: WAP to generate wifi key as user will enter values Name,City,Age and Gender?
A. If gender is Male then key will be First 3 Character of Name+Difference of age digit+Last 3 Character of
city.
B. If gender is Female then key will be last 3 character of Name+sum of age digit+first 3 character of city.

Objective: Implement a Java program that generates Wi-Fi keys based on user-entered information: name,
city, age, and gender. The program dynamically constructs Wi-Fi keys following specific rules based on the
user's gender:

 Male: The Wi-Fi key consists of the first three characters of the name, the difference between the age
digits (positive value), and the last three characters of the city.
 Female: The Wi-Fi key consists of the last three characters of the name, the sum of the age digits, and
the first three characters of the city.

Source Code:
Output:
Problem Statement: WAP to create a method check which returns two values. If first string has a character
twice as well second string also then return the string by removing that character.

Objective: This Java program checks if a specific character appears twice in both input strings and removes
it if found, returning the modified strings.

Source Code:

Output:

1.
Problem Statement: WAP to print number of days gap in your age as enter DD-MM-YYYY with current
system date.

Objective: This Java program calculates the age difference between the user's entered date of birth (DD-
MM-YYYY) and the current system date, and outputs the number of days between those dates.

Source Code:

“”

Output:
Problem Statement: Initialize integer array of any size containing values 0 and 1 only. Now check which is
longest series of either 0 or 1, which is existing. i.e. if array values are {1,1,1,0,0,1,1,0,0,0,0,0,1,1,1} Ans is 0
and length is 5. If there is same series of 0 and 1 then answer will which is existing first i.e., if array values are
{1,1,1,0,0,1,1,0,0,0,1,1,1} Ans is 1 and length is 3

Objective: To develop a Java program that efficiently determines the longest series of 0 or 1 in an integer
array, considering the first-occurring series as the longest if both 0 and 1 series have the same length. The
program should take an array of integers as input and output the value and length of the longest series.

Source Code:
Output:

Problem Statement: Wap to initialize two integer arrays of user entered size. Then perform the following
operations: Add elements in that array which is longest. If the first array is of 3 size having elements 1,2,3.
The second array is of size five and elements are 4,5,6,7,8. The resulting array will be second and now its
elements will 5,7,9,7,8.

Objective: To develop a Java program that initializes two integer arrays of user-entered size, compares their
lengths, and adds the elements of the longer array to a new result array. The program should take the sizes of
the two arrays and their elements as input from the user and output the result array.

Source Code:

Output:

Problem Statement: WAP to show the use of synchronized keyword in producer-consumer problem.
Objective: To implement a producer-consumer problem using the synchronized keyword in Java, where a
Producer thread produces items and adds them to a shared buffer, and a Consumer thread consumes items
from the buffer. The synchronized keyword ensures that only one thread can access the buffer at a time to
avoid data corruption.

Source Code:
Output:

Problem Statement: WAP to show the use of synchronized keyword in producer-consumer problem.
Objective: To implement a producer-consumer problem using the synchronized keyword in Java, where a
Producer thread produces items and adds them to a shared buffer, and a Consumer thread consumes items
from the buffer. The synchronized keyword ensures that only one thread can access the buffer at a time to
avoid data corruption.

Source Code:

Output:

Problem Statement: WAP to show the working of multithreading using a Runnable interface.

Objective: To demonstrate the implementation of multithreading using the Runnable interface in Java. The
program creates two threads, each executing a different task. This showcases the concept of concurrent
execution and the ability of threads to handle multiple tasks simultaneously.

Source Code:

Output:

Problem Statement: WAP to show multithreading working using a Thread Class.

Objective: To demonstrate the implementation of multithreading using the Thread Class in Java. The
program creates two threads, each executing a different task. This showcases the concept of concurrent
execution and the ability of threads to handle multiple tasks simultaneously.
Source Code:

Output:

Problem Statement: WAP to initialize 2D string array at runtime and to print the reverse value of diagonal
position only.

Objective: "The code dynamically creates a 2D string array based on user input for dimensions. After
populating the array with user-provided elements, it prints the reversed values of the elements at diagonal
positions.
Source Code:
Output:

Problem Statement: WAP for following OUTPUT


String s="san12may4tya7yyy678rtb62tp"
Output 1 will 4*7=28
Output 2 will sanmytrbp
Output 3 will 12+678+62=752
Objective: Objective: This program takes a string s as input and performs the following tasks:
Output 1: Compute the product of adjacent single digits in s that are both preceded and succeeded by
alphabets.
Output 2: Extract and display all unique alphabets from s without repetition.
Output 3: Calculate the sum of all 2-digit and 3-digit numbers in s.
Source Code:
Output:

Problem Statement: WAP to create a Form for registration of a user with the following validations. Name
should contain only character values. Address should contain Multiple values. In the subject field select
maximum 2 checkboxes out of three. In the Exam center field select maximum 2 list items.

Objective: This Java program is designed to implement a user registration form with focused validations.
Firstly, it ensures that the user's name input consists exclusively of alphabetic characters. Secondly, the
program accommodates multiple values for the user's address. Furthermore, in the subject field, users are
prompted to select a maximum of two checkboxes out of three. Similarly, in the exam center field, users can
choose up to two items from a provided list. By incorporating these validations, the program seeks to enhance
the accuracy and completeness of user registration information.

Source Code:
Output:

Problem Statement: WAP to put one Exception class in a package and to use this Exception class object in
another package class method anyhow?

Objective: This Java program demonstrates the use of a custom exception class (CustomException) across
packages. The exceptionpackage contains the custom exception, while the mainpackage utilizes this
exception in the MainClass to handle specific cases. The program succinctly illustrates how to structure and
employ custom exceptions seamlessly across different packages in Java.

Source Code:
1.

Output:

Problem Statement: Enter a no and then create array of its digits. i.e. If no is 123456 then store its
digit in int array of size 6 as if array is a than a[0] should be 1 and a[1] should be 2. Also after storing in
array a then reverse its values without using another array i.e. After reversing a[0] should 6 and a[1]
should 5. Print common elements of both arrays.

Objective: This program takes a user-entered number, extracts its digits into an integer array, reverses the
array in-place, and finally, prints the common elements between the original and reversed arrays.

Source Code:
Output:

Problem Statement: WAP to show the use of KeyListener/MouseListener interface in order to


generate and process those events.

Objective: The objective of this code is to create a simple Java Swing application that demonstrates event
handling. The program sets up a JFrame with a JTextField and implements both KeyListener and
MouseListener interfaces. It prints messages to the console when keys are typed and when the mouse is
clicked, providing a basic illustration of handling key and mouse events in a graphical user interface.

Source Code:
Output:

1.
Problem Statement: WAP to create TCP/IP Socket on both client and server side . and after socket creation
perform the Operation as done in chat server.

Objective: Develop a Java program that establishes TCP/IP sockets for both client and server sides, enabling
communication between them. Implement basic chat server functionality, allowing users to exchange
messages through the established socket connection.

Source Code:
Output:

Problem Statement: WAP to print all numeric digits sum of all database column values.
Objective: Create a Java program that connects to a database, retrieves numeric column values, and
calculates the sum of their digits. The program aims to demonstrate database connectivity and numeric digit
manipulation in the context of column values, providing a sum result.

Source Code:
Output:

Problem Statement: WAP in an Applet Make two Button one is Circle within Square and second is Square
within Circle. When user click on Circle within Square then draw Circle within Square. And when user click
on Square within Circle then draw Square within Circle on the panel window?

Objective: To create an applet that draws a circle within a square or a square within a circle based on the
user's button selection.

Source Code:
Output:

1.
Problem Statement: WAP using Applet to draw circle, line, rectangle and fill them with a color given by
the user.

Objective: This applet allows the user to draw circles, lines, and rectangles on the applet window. The user
can also choose the color of the shape they want to draw.

Source Code:
Output:
1.

Problem Statement: WAP to implement a color menu which has four options red, Green, Blue, and Exit.
When we Press red, green, or blue color it will set that color as the background color, and on exit we need to
exit from the window.

Objective: This applet creates four buttons: Red, Green, Blue, and Exit. When a user clicks on a button, the
corresponding color is set as the background color of the applet. When the user clicks on the Exit button, the
applet is closed.

Source Code:
Output:

1.
Problem Statement: WAP to insert/retrieve an image into the database table.
Objective: Create a Java app for inserting and retrieving images from a database table, streamlining image
handling through Java's database connectivity.

Source Code:
Output:

Problem Statement: WAP to update a table column value using stored procedures.
Objective: The code demonstrates a Java program to interact with a MySQL database. It connects to the
database, creates an employees table, inserts sample data, and allows for easy expansion for more
sophisticated database operations.

source code:

Output:

You might also like