You are on page 1of 3

Question 13

Develop an object oriented program in Java to do the following task:


Class Name: Matrix
Member variables:
int a [n] [n] : to store the elements of the matrix of (n x n) order.
Rest of the member variables can be assumed as required.
Public Member functions:
void row_Wise_Sum (int , int) : to find the row-wise sum of all the elements.
void right_uptriangle(int , int) : to display right upper triangular elements of a[ ][ ]
int max_2(int , int) : to return the 2nd maximum element of the Matrix without
sorting.
void getData ( ) : to accept the elements of the matrix & the order of the Matrix.
void display (int , int ) : to display the elements of the matrix using one loop only.
int calculate(int n) : to pass the matrix a[ ][ ] & the order of the matrix i.e. n.
Test your class using the main ( ) method.

Question 14
A class String_Op is designed to sort the words of a sentence alphabetically.
Data member:
String txt : to store the sentence end with full stop.
Rest of the member variables can be assumed as required.
Member function:
void readString ( ) : to accept the sentence
char caseConvert (char) : to convert Upper case to Lower case & vice versa
without using any String function.
String sort ( String ) : to sort the words of the sentence alphabetically using
Bubble Sort
void display(String ) : to display the sorted string & new String after case \
conversion.
Write a main ( ) to call the methods using the object.

Question 15
Write a program in Java to accept the elements in a square matrix of order n x n
then transpose the elements of the matrix & finally display the mirror image of that
transpose form along with the original form.
Sample Input: Enter the order of the matrix (n) = 3
The Matrix is: 1 2 3 Transpose form: 1 4 7 Mirror Image: 7 4 1
489 286 682
765 395 593
Output should be taken using both odd ordered and even ordered matrices.

Question 16:
Write a program in Java to store ‘ N ’ numbers in a text file “Number.txt” then
display all the Prime numbers and Palindrome numbers with a proper message.
Question 17:
Write a program in Java to accept a string. Count and display the frequency of each
character present in the string. The character with multiple frequencies should be displayed
only once.

Sample Input:

golden jubilee

Sample Output:

Alphabet g o l d e n j u b i

Frequency 1 1 2 1 3 1 1 1 1 1

Question 18
Write a program in Java to accept two strings. Display the new string by taking each
character of the first string from left to right and of the second string from right to left. The
letters should be taken alternatively from each string. Assume that the length of both the
strings are same.

Sample Input:
String 1: HISTORY
String 2: SCIENCE

Sample Output:
HEICSNTEOIRCYS

Question 19
Write a program to input and store n integers (n > 0) in a single subscripted variable and
print each number with its frequency. The output should contain number and its frequency in
two different columns.

Sample Input:

12 20 14 12 12 20 16 16 14 14 12 20 18 18

Sample Output:

Number Frequency

12 4
14 3

16 2

18 2

20 3

Question 20
Write a class with the name Perimeter using function overloading that computes the
perimeter of a square, a rectangle and a circle.
Formula:
Perimeter of a square = 4 * s
Perimeter of a rectangle = 2 * (l + b)
Perimeter of a circle = 2 * (22/7) * r

You might also like