Sie sind auf Seite 1von 3

Q1. Write a program to store 20 countries name and capitals name in array CA[] and CO[].

When the user inputs a


country name the program displays the Capital name, If the country name is not present then the program shows an
appropriate error message.
Q2. Write a class to accept a number and check whether it is a Prime-palindrome number or Armstrong number
based on users choice.
Prime-palindrome number - a number is a prime no. and palindrome no. Eg. 101
Armstrong number - Sum of the cubes of the digits = number Eg. 153 [15]
Q3. Write a class to input a string (combination of letters and digits) and replace the repeated characters with an
asterisk (*) sign. Then display both old and newly created string
Q4. Write a program to display hcf and lcm of any two nos.
Q5. Write a program to read a positive integer from the console and find out whether it is automorphic or not.
(Automorphic numbers are those which are found on the extreme right side of their square).
Eg. 52 = 25, 62 = 36, 252 = 625 . 5,6,25 are automorphic numbers.
Q 6. Write a method namely Revwords() of class strings that should receive a string and return the strings with its
words reversed individually e.g. if you pass I love Java, it should return I evol avaJ
Q7. Write a program to input a string and display the string with the first character of every word in capital and the
rest of the word in small letters.
Q 8. write a program in java to read a number having more than 5 digits and print whether the given number is
divisible by 11 or not. A number is divisible by 11 if and only if the difference of the sums of digits at odd positions and
even positions is either zero or divisible by 11
Q9. Write a program to input twenty names in an array and display all the names whose first alphabet matches with
the alphabet entered by the user.
Q 10. Write a program using string function to input any string and print the same in alphabetical order.
Q 11. Write a program to enter a sentence and display the following.
1.

Number of upper case letters

2.

Number of lower case letters

3.

Number of uppercase vowels and lowercase vowels.

4.

Number of consonants

5.

Number of blank spaces

6.

Number of special character

Q 12. The single dimensional arrays A and B are sorted in ascending order. Create an array C to combine them into a
descending order.(10)
1.

Q 13. Primorial(p#) is defined to be a product of prime numbers less than or equal to p. (15)

For eg. 3# =2*3=6 5# =2*3*5=30 Design a class primo_numb with two methods
1.

to check whether entered number is prime number or not

2.

to print the primorial of that number.

Q 13. Write a prog to input a string and two words and replace first word with second word as in sample example:
Input: hot plate with hot egg
Word 1: hot
Word2: cold
Output: cold plate with cold egg
Q 14. WAP to input a name and print its initials as
Input Subhas Chandra Bose
Output:
(i) S.C.Bose
(ii) Bose, S.C.
(iii) S.C.B.
Q 15. WAP to input name and total marks of 50 students and now input a name and check whether this name exist in
list or not , if it is exist then print this name and marks in the given format otherwise print a suitable message to show
that name does not exist.
Name :- xxxxxx
Marks obtained - ******** ( X and stars denote values of the variables).
Q 16. Write a program in java to input a sentence and find out how many palindromes are there in the sentence also
print the palindromes.
Q 17. Write a program in java to input a sentence and find out the sum of the ASCII values of the characters.
Q 18. Write a program in java create function area() to find

i) area of circle
ii) area of rectangle
ii) area of trangle().
Q 19. Write a program in java create function reverse() to
i) reverse a number
ii) reverse a string.
Q 20 Write a program in java to input a sentence and replace each vowel with its nextg letter.
Computer will be Cpmpvtfr(o-p, u-v, e f)

Das könnte Ihnen auch gefallen