0% found this document useful (0 votes)
154 views2 pages

Java Test and Solutions

The document contains 14 programming problems involving string manipulation, number checking, date/time calculations, arrays, and matrices. Some examples include checking if two strings are anagrams, finding duplicate characters in a string, determining if a number is Armstrong, finding the largest number less than a given number without a certain digit, and performing matrix operations like addition, subtraction, multiplication, and transposition.

Uploaded by

Achint Rathi
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)
154 views2 pages

Java Test and Solutions

The document contains 14 programming problems involving string manipulation, number checking, date/time calculations, arrays, and matrices. Some examples include checking if two strings are anagrams, finding duplicate characters in a string, determining if a number is Armstrong, finding the largest number less than a given number without a certain digit, and performing matrix operations like addition, subtraction, multiplication, and transposition.

Uploaded by

Achint Rathi
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
You are on page 1/ 2

1. Write a java program to check whether two given strings are anagram or not.

Two strings
are said to be anagram if they contain same set of characters but in different order. For
example, “Mother In Law” and “Hitler Woman” are anagrams.

2. Write a java program to find duplicate characters and their count in a given string. For
example, in a string “Better Butter”, duplicate characters and their count is t : 4, e : 3, r : 2
and B : 2.

3. Write a java program to check whether a given number is Armstrong number or not. A
number is called an Armstrong number if it is equal to sum of its digits each raised to the
power of number of digits in it. For example: 153, 9474, 54748 are some Armstrong
numbers.

4. Write a java program to find the largest number ‘L’ less than a given number
‘N’ which should not contain a given digit ‘D’. For example, If 145 is the given number and 4
is the given digit, then you should find the largest number less than 145 such that it should
not contain 4 in it. In this case, 139 will be the answer.

5. Write a java program to check whether given number is binary or not. A binary number is a
number which contains only 0 or 1. For example : 101101, 110010110, 10010011 are binary
numbers.

6. Write a java program to reverse each word of a given string. For example, If “Java Concept
Of The Day” is input string then output should be “avaJ tpecnoC fO ehT yaD”.

7. Write a java program to convert decimal to binary, decimal to octal and decimal to
hexadecimal.

8. Write a java program to generate random numbers.

9. Write a java program to find the most repeated word in text file. Your program should take
one text file as input and find out the most repeated word in that file

10. Write a java program to swap two string variables without using third or temp variable?

11. Your program should take start date and end date from the user and find out the difference
between these two dates in terms of years, days, hours, minutes and seconds.Write this
program as described.

12. Write a java program to find all pairs of elements in the given array whose sum is equal to a
given number. For example, if {4, 5, 7, 11, 9, 13, 8, 12} is an array and 20 is the given
number, then you have to find all pairs of elements in this array whose sum must be 20. In
this example, (9, 11), (7, 13) and (8, 12) are such pairs whose sum is 20.

13. Write a java program to find sum of all digits of a given number
14. Write a java program to perform matrix operations like matrix addition, matrix subtraction,
matrix multiplication and transpose of a matrix.

You might also like