0% found this document useful (0 votes)
18 views1 page

Java Programming Lab Exercises

The document is a worksheet for an Object Oriented Programming lab using Java, containing 11 programming tasks. These tasks include operations with arrays, user input handling, string manipulation, and matrix operations. Each task requires writing Java code to accomplish specific objectives such as calculating sums, sorting, checking palindromes, and modifying strings.

Uploaded by

eyuelmengistub
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)
18 views1 page

Java Programming Lab Exercises

The document is a worksheet for an Object Oriented Programming lab using Java, containing 11 programming tasks. These tasks include operations with arrays, user input handling, string manipulation, and matrix operations. Each task requires writing Java code to accomplish specific objectives such as calculating sums, sorting, checking palindromes, and modifying strings.

Uploaded by

eyuelmengistub
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

Worksheet 5

For each of the problems write a Java code to perform the required task.
Course Title: Object Oriented Programming using Java
Lab: Array and String
1. Store the age of six of your friends in a single array. Store each of the six ages using the
assignment operator. Print the ages on the screen.
2. Accept 10 integers from the user and finally
a. Display the sum of the elements
b. Display the smallest value and the largest value.
c. Display the numbers in ascending order.
d. Display the numbers in descending order
3. Write a Java program that reads in ten numbers from user and displays the distinct
numbers. (i.e., if a number appears multiple times, it is displayed only once).
4. Write a Java program that reads two 3x3 matrices and print addition of the two matrices.
5. Write a java program that accepts ten names and display them in alphabetical order.
6. Accept a word from the user and check whether the word is palindrome or not. (NB: a
word is palindrome if it is readable from left to right as well as right to left).
7. Accept the name of a person and then counts how many vowels the person’s name have.
8. Modify the question in question 5 in such a way that it should replace vowel characters
with * in the person name.
9. Write a Java program that accepts any text from keyboard and reverse the string using the
reverse method in the StringBuilder class.
10. Write a Java program that accepts any text having at least 20 characters from keyboard
and delete a substring from a string of 20 characters, starting at index 4 and ending with
index 10. Use the delete method in the StringBuilder class.
11. Write a Java program that accepts one line of text from user in small letter and change the
string into capital letters and vice versa. Finally break down the sentence into number of
words.

You might also like