0% found this document useful (0 votes)
18 views3 pages

Java Programming Tasks and Examples

The document contains a series of programming tasks in Java, each consisting of two sections: the first section typically involves writing a program for a specific functionality, while the second section often requires creating a multi-threaded application or handling user input and events. The tasks cover a wide range of topics including prime number generation, matrix multiplication, string manipulation, file handling, and GUI development. The document serves as a comprehensive guide for practicing Java programming skills across various concepts.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views3 pages

Java Programming Tasks and Examples

The document contains a series of programming tasks in Java, each consisting of two sections: the first section typically involves writing a program for a specific functionality, while the second section often requires creating a multi-threaded application or handling user input and events. The tasks cover a wide range of topics including prime number generation, matrix multiplication, string manipulation, file handling, and GUI development. The document serves as a comprehensive guide for practicing Java programming skills across various concepts.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

1.

Answer both the sections


a. Write a Java program to find and print all prime numbers up to a given number.
b. Create a multi-threaded program where one thread generates random numbers, and another
thread prints the square if it’s even and the cube if it’s odd.

2. Answer both the sections


a. Write a Java program to multiply two matrices.
b. Create a program to print numbers from 1 to 10 using one thread and from 90 to 100 using
another thread.

3. Answer both the sections


a. Write a Java program to count the characters, words, and lines in a text.
b. Write a program that accepts a file name and displays whether the file exists, is readable,
writable, and its length.

4. Answer both the sections


a. Write a Java program that generates random numbers between two limits and prints a
message based on the value.
b. Create a simple text editor that lets users change the text size and font, and apply bold or
italic formatting.

5. Answer both the sections


a. Write a Java program using a character array to find the length of a string, find a character at
a position, and concatenate two strings.
b. Write a Java program that handles mouse events and shows the event name at the center of
the window.

6. Answer both the sections


a. Write a Java program to perform string operations: concatenate, search for a substring, and
extract a substring.
b. Write a calculator program using a grid layout with buttons for numbers and operations (+, -,
*, %), and display the result in a text field.

7. Answer both the sections


a. Write a Java program using StringBuffer to find the length of a string, reverse it, and delete a
substring.
b. Create a traffic light simulation where users select a light (red, yellow, or green), and a
corresponding message ("stop," "ready," or "go") appears in color.

8. Answer both the sections


a. Write a Java program to print all prime numbers up to a user-given number.
b. Create a simple calculator with three text boxes and radio buttons for operations. Display the
result in the third text box.

9. Answer both the sections


a. Write a Java program to multiply two matrices and display the result.
b. Write a program that demonstrates handling exceptions like ArithmeticException,
NumberFormatException, and ArrayIndexOutOfBoundsException.
10. Answer both the sections
a. Write a Java program that counts the number of characters, words, and lines in a given text
file.
b. Write a program to check a file's existence, readability, writability, and size based on user
input.

11. Answer both the sections


a. Write a program to find the length of a string and concatenate two strings using character
arrays.
b. Create a multi-threading program that generates random numbers, squares even numbers, and
cubes odd numbers.

12. Answer both the sections


a. Write a Java program that performs string manipulation using StringBuffer: reverse a string,
find its length, and delete a substring.
b. Write a simple calculator with buttons for arithmetic operations (+, -, *, %) and a text box for
displaying the result.

13. Answer both the sections


a. Write a program to concatenate two strings and search for a substring within them.
b. Create a program to simulate traffic lights and display appropriate messages when a light
(red, yellow, or green) is selected.

14. Answer both the sections


a. Write a Java program to generate random numbers between two limits and print appropriate
messages based on the value.
b. Write a program that demonstrates exception handling for common exceptions like
ArithmeticException and ArrayIndexOutOfBoundsException.

15. Answer both the sections


a. Write a Java program that prompts the user for an integer and prints all prime numbers up to
that integer.
b. Create a program where two threads print numbers asynchronously, one printing 1 to 10 and
the other printing 90 to 100.

16. Answer both the sections


a. Write a Java program to multiply two given matrices.
b. Create a simple text editor with options to change text size, font, and apply bold or italic
styles.

17. Answer both the sections


a. Write a Java program to count the number of characters, words, and lines in a text file.
b. Create a program to handle mouse events and display the event name in the window center.

18. Answer both the sections


a. Write a Java program to perform string concatenation and substring extraction using the
String class.
b. Create a calculator using a grid layout with buttons for digits and operations, displaying the
result in a text field.
19. Answer both the sections
a. Write a Java program using StringBuffer to reverse a string and delete a specific substring.
b. Write a Java program that simulates a traffic light system with radio buttons and displays
appropriate messages based on the selection.

20. Answer both the sections


a. Write a Java program that generates random numbers and prints messages based on the
number’s value.
b. Create a program to handle basic file operations, displaying file information like type, length,
and accessibility.

21. Answer both the sections


a. Write a program to perform string operations like finding length and concatenation using a
character array.
b. Write a program to handle multiple exceptions: ArithmeticException,
ArrayIndexOutOfBoundsException, and NumberFormatException.

22. Answer both the sections


a. Write a Java program to search for a substring in a string and extract it.
b. Write a Java program that implements a simple GUI calculator with three text boxes for
input, operations, and result.

23. Answer both the sections


a. Write a program to reverse a string and delete a part of it using StringBuffer.
b. Write a traffic light simulation program where users can select a light, and an appropriate
message is displayed in color.

24. Answer both the sections


a. Write a Java program that counts characters, words, and lines in a text file.
b. Create a simple text editor that allows users to format text by changing its size and font.

25. Answer both the sections


a. Write a Java program to find the length of a string and concatenate two strings using the
String class.
b. Create a program where two threads run simultaneously to print numbers from 1 to 10 and 90
to 100.
***************************************************************************************

You might also like