1) WAP to enter the five elements in array and show it
2) WAP to enter the five elements in array and calculate the sum of all elements
a[0] a[1] a[2] a[3] a[4]
10 20 30 40 50
Output : Sum of all array elements : 150
2) WAP to enter the five elements in array and find out the maximum and minimum elements
a[0] a[1] a[2] a[3] a[4]
Output like as
Maximum element in array : 11
Minimum element in array : 4
3)WAP to enter the five element and display in ascending order ?
a[0] a[1] a[2] a[3] a[4]
53641
Output like as
13456
4) WAP to insert the element on specified position in array ?
e.g. declare the array of size 6 and store 5 values in it and last block should be empty
a[0] a[1] a[2] a[3] a[4] a[5]
10 20 30 40 50
Enter the index on which value want to be insert
e.g. index = 2
Enter the value which want to store on index
Value = 100
When we insert the value on index then we need to shift the values from index to next index
e.g.
a[0] a[1] a[2] a[3] a[4]
5 9 11 4 6
10 20 100 30 40 50
5). Write a program to enter the 5 values in ascending order and store in array and find out the
missing element from array?
a[0] a[1] a[2] a[3] a[4]
1 5 9 13 17
Missing elements : output should like as
2 3 4 6 7 8 10 11 12 14 15 16
6).WAP to enter the five element in array and reverse it ?
e.g.
a[0] a[1] a[2] a[3] a[4]
10 20 30 40 50
After Reverse Array should like as
a[0] a[1] a[2] a[3] a[4]
50 40 30 20 10
7) WAP to enter the 10 element array and print the occurrence of every element ?
a[0] a[1] a[2] a[3] a[4] a[5] a[6] a[7] a[8] a[9]
10 20 30 10 20 50 30 10 30 10
Output :
Element count
10 -------------------- 4
20 -------------------- 2
30 -------------------- 3
50 ------------------ 1
8) . Write a program in C to merge two arrays of same size sorted in decending order.
Test Data :
Input the number of elements to be stored in the first array :3
Input 3 elements in the array :
element - 0 : 1
element - 1 : 2
element - 2 : 3
Input the number of elements to be stored in the second array :3
Input 3 elements in the array :
element - 0 : 1
element - 1 : 2
element - 2 : 3
Expected Output :
The merged array in decending order is :
332211
9) . Write a program in C to separate odd and even integers in separate arrays ?
Test Data :
Input the number of elements to be stored in the array :5
Input 5 elements in the array :
element - 0 : 25
element - 1 : 47
element - 2 : 42
element - 3 : 56
element - 4 : 32
Expected Output :
The Even elements are :
42 56 32
The Odd elements are :
25 47
10). Write a program in C to delete an element at desired position from an array.
Test Data :
Input the size of array : 5
Input 5 elements in the array in ascending order:
element - 0 : 1
element - 1 : 2
element - 2 : 3
element - 3 : 4
element - 4 : 5
Input the position where to delete: 3
Expected Output :
The new list is : 1 2 4 5
11). Write a program in C to find the second largest element in an array ?
Test Data :
Input the size of array : 5
Input 5 elements in the array :
element - 0 : 2
element - 1 : 9
element - 2 : 1
element - 3 : 4
element - 4 : 6
Expected Output :
The Second largest element in the array is : 6
12) . Write a program in C to find a pair with given sum in the array.
Expected Output :
The given array : 6 8 4 -5 7 9
The given sum : 15
Pair of elements can make the given sum by the value of index 0 and 5
13) Write a program in C to find the majority element of an array ?
A majority element in an array A[] of size n is an element that appears more than n/2 times (and
hence there is at most one such element).
Expected Output :
The given array is : 4 8 4 6 7 4 4 8
There are no Majority Elements in the given array.
14) Write a program in C to rotate an array by N positions ?
Expected Output :
The given array is : 0 3 6 9 12 14 18 20 22 25 27
From 4th position the values of the array are : 12 14 18 20 22 25 27
Before 4th position the values of the array are : 0 3 6 9
After rotating from 4th position the array is:
12 14 18 20 22 25 27 0 3 6 9
15) Write a program in C to find the ceiling in a sorted array?
Given a sorted array in ascending order and a value x, the ceiling of x is the smallest element in array
greater than or equal to x, and the floor is the greatest element smaller than or equal to x.
Expected Output :
The given array is : 1 3 4 7 8 9 9 10
The ceiling of 5 is: 7
16). Write a program in C to find the Floor and Ceil of the number 0 to 10 from a sroted array.
Expected Output :
The given array is : 1 3 5 7 8 9
Number: 0 ceiling is: 1 floor is: -1
Number: 1 ceiling is: 1 floor is: 1
Number: 2 ceiling is: 3 floor is: 1
Number: 3 ceiling is: 3 floor is: 3
Number: 4 ceiling is: 5 floor is: 3
Number: 5 ceiling is: 5 floor is: 5
Number: 6 ceiling is: 7 floor is: 5
Number: 7 ceiling is: 7 floor is: 7
Number: 8 ceiling is: 8 floor is: 8
Number: 9 ceiling is: 9 floor is: 9
Number: 10 ceiling is: -1 floor is: 9
17) Write a program in C to find the smallest missing element from a sorted array?
Expected Output :
The given array is : 0 1 3 4 5 6 7 9
The missing smallest element is: 2
18) Write a program in C to to print next greater elements in a given unsorted array. Elements for
which no greater element exist, consider next greater element as -1.
Expected Output :
The given array is : 5 3 10 9 6 13
Next Bigger Elements are:
Next bigger element of 5 in the array is: 10
Next bigger element of 3 in the array is: 10
Next bigger element of 10 in the array is: 13
Next bigger element of 9 in the array is: 13
Next bigger element of 6 in the array is: 13
Next bigger element of 13 in the array is: -1
Next Bigger Elements Array:
10 10 13 13 13 -1
19) Write a program in C to find two elements whose sum is closest to zero
Expected Output :
The given array is : 38 44 63 -51 -35 19 84 -69 4 -46
The Pair of elements whose sum is minimum are:
[44, -46]
20) Write a program in C to find a subarray with given sum from the given array?
Expected Output :
The given array is : 3 4 -7 1 3 3 1 -4
[0..1] -- { 3 4 }
[0..5] -- { 3 4 -7 1 3 3 }
[3..5] -- { 1 3 3 }
[4..6] -- { 3 3 1 }
21) Write a program in C to find if a given integer x appears more than n/2 times in a sorted array
of n integers ?
Expected Output :
The given array is : 1 3 3 5 4 3 2 3 3
The given value is : 3
3 appears more than 4 times in the given array[]
22) Write a program in C to find the maximum circular subarray sum of a given array.
Expected Output :
The given array is : 10 8 -20 5 -3 -5 10 -13 11
The maximum circular sum in the above array is: 29
23) Write a program in C to move all zeroes to the end of a given array.
Expected Output :
The given array is : 2 5 7 0 4 0 7 -5 8 0
The new array is:
2 5 7 8 4 -5 7 0 0 0
24) Write a program in C to count the number of inversion in a given array
Expected Output :
The given array is : 1 9 6 4 5
The inversions are: (9, 6) (9, 4) (9, 5) (6, 4) (6, 5)
The number of inversion can be formed from the array is: 5
25) Write a program in C to find out the maximum difference between any two elements such that
larger element appears after the smaller number.
Expected Output :
The given array is : 7 9 5 6 13 2
The elements which provide maximum difference is: 5, 13
The Maximum difference between two elements in the array is: 8
26) Write a program in C to count all distinct pairs for a specific difference
Expected Output:
The given array is:
52376498
The distinct pairs for difference 5 are: [7, 2] [8, 3] [9, 4]
Number of distinct pairs for difference 5 are: 3
27) Write a program in C to find the maximum repeating number in a given array.
The array range is [0..n-1] and the elements are in the range [0..k-1] and k<=n..
Expected Output:
The given array is:
23353417777
The maximum repeating number is: 7
28)Write a program in C to print all possible combinations of r elements in a given array.
Expected Output:
The given array is:
1 5 4 6 8 The combination from by the number of elements are: 4
The combinations are:
1546
1548
1568
1468
5468
29) Write a program in C to find a pair with the given difference
Expected Output:
The given array is:
1 15 39 75 92
The given difference is: 53
The pair are: (39, 92)
30) Write a program in C to find the minimum distance between two numbers in a given array.
Expected Output:
The given array is:
7 9 5 11 7 4 12 6 2 11
The minimum distance between 7 and 11 is: 1
31) Write a program in C to rearrange positive and negative numbers alternatively in a given array
Output:
If positive numbers are more they appear at the end and for also negative numbers, they too appear
in the end of the array.
Expected Output:
The given array is:
-4 8 -5 -6 5 -9 7 1 -21 -11 19
The rearranged array is:
-4 7 -5 1 -21 5 -11 8 -9 19 -6
32)Write a program in C to find the maximum for each and every contigious subarray of size k
from a given array.
Expected Output:
The given array is:
1 3 6 21 4 9 12 3 16 10
The length of each subarray is: 4
The contagious subarray of length 4 and their maximum value are:
1 3 6 21 ----> 21
3 6 21 4 ----> 21
6 21 4 9 ----> 21
21 4 9 12 ----> 21
4 9 12 3 ----> 12
9 12 3 16 ----> 16
12 3 16 10 ----> 16
33) Write a program in C to convert the array in such a way that double its value and replace the
next number with 0 if current and next element are same and rearrange the array such that all 0's
shifted to the end.
Expected Output:
The given array is: 0 3 3 3 0 0 7 7 0 9
The new array is: 6 3 14 9 0 0 0 0 0 0
34)Remove duplicates from unsorted array using Set data structure
Given an unsorted array of integers, print the array after removing the duplicate elements from it.
We need to print distinct array elements according to their first occurrence.
Examples:
Input: arr[] = { 1, 2, 5, 1, 7, 2, 4, 2}
Output: 1 2 5 7 4
Explanation: {1, 2} appear more than one time.
Input: arr[] = { 3, 3, 4, 1, 1}
Output: 3 4 1
35) Write a program in C for a 2D array of size 3x3 and print the matrix ?
Test Data :
Input elements in the matrix :
element - [0],[0] : 1
element - [0],[1] : 2
element - [0],[2] : 3
element - [1],[0] : 4
element - [1],[1] : 5
element - [1],[2] : 6
element - [2],[0] : 7
element - [2],[1] : 8
element - [2],[2] : 9
Expected Output :
The matrix is :
123
456
789
36)Write a program in C for addition of two Matrices of same size.
Test Data :
Input the size of the square matrix (less than 5): 2
Input elements in the first matrix :
element - [0],[0] : 1
element - [0],[1] : 2
element - [1],[0] : 3
element - [1],[1] : 4
Input elements in the second matrix :
element - [0],[0] : 5
element - [0],[1] : 6
element - [1],[0] : 7
element - [1],[1] : 8
12
34
The Second matrix is :
56
78
The Addition of two matrix is :
68
10 12
37) Write a program in C for subtraction of two Matrices.
Test Data :
Input the size of the square matrix (less than 5): 2
Input elements in the first matrix :
element - [0],[0] : 5
element - [0],[1] : 6
element - [1],[0] : 7
element - [1],[1] : 8
Input elements in the second matrix :
element - [0],[0] : 1
element - [0],[1] : 2
element - [1],[0] : 3
element - [1],[1] : 4
Expected Output :
The First matrix is :
56
78
The Second matrix is :
12
34
The Subtraction of two matrix is :
44
44
38)Write a program in C for multiplication of two square Matrices
Test Data :
Input the rows and columns of first matrix : 2 2
Input the rows and columns of second matrix : 2 2
Input elements in the first matrix :
element - [0],[0] : 1
element - [0],[1] : 2
element - [1],[0] : 3
element - [1],[1] : 4
Input elements in the second matrix :
element - [0],[0] : 5
element - [0],[1] : 6
element - [1],[0] : 7
element - [1],[1] : 8
Expected Output :
The First matrix is :
12
34
The Second matrix is :
56
78
The multiplication of two matrix is :
19 22
43 50
39)Write a program in C to find transpose of a given matrix.
Test Data :
Input the rows and columns of the matrix : 2 2
Input elements in the first matrix :
element - [0],[0] : 1
element - [0],[1] : 2
element - [1],[0] : 3
element - [1],[1] : 4
Expected Output :
The matrix is :
12
34
The transpose of a matrix is :
13
24
40)Write a program in C to find sum of right diagonals of a matrix
Test Data :
Input the size of the square matrix : 2
Input elements in the first matrix :
element - [0],[0] : 1
element - [0],[1] : 2
element - [1],[0] : 3
element - [1],[1] : 4
Expected Output :
The matrix is :
12
34
Addition of the right Diagonal elements is :5
41)Write a program in C to find the sum of left diagonals of a matrix.
Test Data :
Input the size of the square matrix : 2
Input elements in the first matrix :
element - [0],[0] : 1
element - [0],[1] : 2
element - [1],[0] : 3
element - [1],[1] : 4
Expected Output :
The matrix is :
12
34
Addition of the left Diagonal elements is :5
42)Write a program in C to find sum of rows an columns of a Matrix.
Test Data :
Input the size of the square matrix : 2
Input elements in the first matrix :
element - [0],[0] : 5
element - [0],[1] : 6
element - [1],[0] : 7
element - [1],[1] : 8
Expected Output :
The First matrix is :
The matrix is :
56
78
The sum or rows and columns of the matrix is :
5 6 11
7 8 15
12 14
43) Write a program in C to print or display the lower triangular of a given matrix.
Test Data :
Input the size of the square matrix : 3
Input elements in the first matrix :
element - [0],[0] : 1
element - [0],[1] : 2
element - [0],[2] : 3
element - [1],[0] : 4
element - [1],[1] : 5
element - [1],[2] : 6
element - [2],[0] : 7
element - [2],[1] : 8
element - [2],[2] : 9
Expected Output :
The matrix is :
123
456
789
Setting zero in lower triangular matrix
123
056
009
44)Write a program in C to print or display upper triangular matrix
Input the size of the square matrix : 3
Input elements in the first matrix :
element - [0],[0] : 1
element - [0],[1] : 2
element - [0],[2] : 3
element - [1],[0] : 4
element - [1],[1] : 5
element - [1],[2] : 6
element - [2],[0] : 7
element - [2],[1] : 8
element - [2],[2] : 9
Expected Output :
The matrix is :
123
456
789
Setting zero in upper triangular matrix
100
450
789
45)Write a program in C to calculate determinant of a 3 x 3 matrix.
Test Data :
Input elements in the first matrix :
element - [0],[0] : 1
element - [0],[1] : 0
element - [0],[2] : -1
element - [1],[0] : 0
element - [1],[1] : 0
element - [1],[2] : 1
element - [2],[0] : -1
element - [2],[1] : -1
element - [2],[2] : 0
Expected Output :
The matrix is :
1 0 -1
001
-1 -1 0
The Determinant of the matrix is: 1
46)Write a program in C to accept a matrix and determine whether it is a sparse matrix.
Test Data :
Input the number of rows of the matrix : 2
Input the number of columns of the matrix : 2
Input elements in the first matrix :
element - [0],[0] : 0
element - [0],[1] : 0
element - [1],[0] : 1
element - [1],[1] : 0
Expected Output :
The given matrix is sparse matrix.
There are 3 number of zeros in the matrix
47)Write a program in C to accept two matrices and check whether they are equal
Test Data :
Input Rows and Columns of the 1st matrix :2 2
Input Rows and Columns of the 2nd matrix :2 2
Input elements in the first matrix :
element - [0],[0] : 1
element - [0],[1] : 2
element - [1],[0] : 3
element - [1],[1] : 4
Input elements in the second matrix :
element - [0],[0] : 1
element - [0],[1] : 2
element - [1],[0] : 3
element - [1],[1] : 4
Expected Output :
The first matrix is :
12
34
The second matrix is :
12
34
The Matrices can be compared :
Two matrices are equal.
48)Write a program in C to check whether a given matrix is an identity matrix.
Test Data :
Input number of Rows for the matrix :3
Input number of Columns for the matrix :3
Input elements in the first matrix :
element - [0],[0] : 1
element - [0],[1] : 0
element - [0],[2] : 0
element - [1],[0] : 0
element - [1],[1] : 1
element - [1],[2] : 0
element - [2],[0] : 0
element - [2],[1] : 0
element - [2],[2] : 1
Expected Output :
The matrix is :
100
010
001
TProgram on Looping
1. Write a C program to print all natural numbers from 1 to n. - using while loop
2. Write a C program to print all natural numbers in reverse (from n to 1). - using while loop
3. Write a C program to print all alphabets from a to z. - using while loop
4. Write a C program to print all even numbers between 1 to 100. - using while loop
5. Write a C program to print all odd number between 1 to 100.
6. Write a C program to find sum of all natural numbers between 1 to n.
7. Write a C program to find sum of all even numbers between 1 to n.
8. Write a C program to find sum of all odd numbers between 1 to n.
9. Write a C program to print multiplication table of any number.
10. Write a C program to count number of digits in a number.
11. Write a C program to find first and last digit of a number.
12. Write a C program to find sum of first and last digit of a number.
13. Write a C program to swap first and last digits of a number.
14. Write a C program to calculate sum of digits of a number.
15. Write a C program to calculate product of digits of a number.
16. Write a C program to enter a number and print its reverse.
17. Write a C program to check whether a number is palindrome or not.
18. Write a C program to find frequency of each digit in a given integer.
19. Write a C program to enter a number and print it in words.
20. Write a C program to print all ASCII character with their values.
21. Write a C program to find power of a number using for loop.
22. Write a C program to find all factors of a number.
23. Write a C program to calculate factorial of a number.
24. Write a C program to find HCF (GCD) of two numbers.
25. Write a C program to find LCM of two numbers.
26. Write a C program to check whether a number is Prime number or not.
27. Write a C program to print all Prime numbers between 1 to n.
28. Write a C program to find sum of all prime numbers between 1 to n.
29. Write a C program to find all prime factors of a number.
30. Write a C program to check whether a number is Armstrong number or not.
31. Write a C program to print all Armstrong numbers between 1 to n.
32. Write a C program to check whether a number is Perfect number or not.
33. Write a C program to print all Perfect numbers between 1 to n.
34. Write a C program to check whether a number is Strong number or not.
35. Write a C program to print all Strong numbers between 1 to n.
36. Write a C program to print Fibonacci series up to n terms.
Patterns Assignment
Floyd’s Triangle Pattern Program in C, C++, Java, Python
Pascal’s Triangle Pattern Program in C, C++, Java, Python
Hollow Diamond Inscribed in a Rectangle
Hollow Diamond Inscribed in a Rectangle
Butterfly Pattern Printing
Diagonal & Sides of a Rhombus/Diamond
Rhombus Pattern Program in C, C++, Java
Traingle with numbers
C program to print following Pyramid:
00
01 01
010 010
0101 0101
0101001010
C program to print following Pyramid:
11
12 21
123 321
1234 4321
1234554321
C program to print following pyramid
123454321
1234321
12321
121
C program to print character pyramid as given below:
BC
DEF
GHIJ
KLMNO
/*
C program to print following character pyramid:
ABCDEDCBA
ABCD DCBA
ABC CBA
AB BA
AA
*/
/*
C program to print following pyramid:
BAB
CBABC
DCBABCD
EDCBABCDE
*/
/*
C program to print following pyramid
ABA
ABCBA
ABCDCBA
ABCDEDCBA
*/he matrix is an identity matrix.
Program for practice
Q1. Write a program to create class name as Cube with two methods
void setValue(int x): this function accept number as parameter
int getCube(): this function can calculate cube of number and return it.
Q2. Write program to create class name as Factorial with two functions
void setValue(int x): this function accept number as parameter
int getFactorial(): this function can calculate factorial of number and return it.
Q3. Write program to create class name as CheckChar with two functions
void setChar(char ch): this function accept single character as input
boolean checkChar(): this function can check character is alphabet or digit of special symbol if
character is alphabet or digit return true if character is digit then return false.
Q3. Write program to create class name as FindMax with two functions
void setArray(int a[]): this function is used for accept array as parameter
int getMax(): this function can find the max value from array and return it.
Q4. Write program to create class name as SortArr with two functions
void setArray(int a[]): this function can accept array as parameter
int [] getSortArray(): this function can perform sorting on array and return sorted array
Q5. Write program to create POJO class name as Employee with id,name and salary attribute and public
class Aptitude {
static int a;
public static void main(String[] args) {
int b;
System.out.println(a);
System.out.println(b);
store data in object and retrieve data from object
Q6. Write program to create class name as CheckDuck with parameterized constructor
CheckDuck(int no): this constructor can accept number as parameter
Boolean isDuckNumber(): this function check if number is duck return true otherwise return false.
Q7. Write program to create class name as Area with constructor overloading
Area(float radius): this function can accept radius as input and calculate circle Area
Area(int len,int width): this function can accept len and width as input and calculate area of
rectangle
Q8. Write program to create class name as MergeTwoArray with parameterized constructor
MergeTwoArray(int [],int []): this constructor accept two array as parameter
int [] getMergeArray(): this function merge two array in third array and return new merged array
Q9. Write program for write code for singleton class?
Q10. Write code for utility class?
Programming Question
________________________________________________________
Q1. Write a program to crate class name as Value with single function name as setValue(int,int) and
we have to create three child classes name as Add with function int getAdd() , Mul with function
getMul() and Div with function getDiv() and getAdd() function return addition of two value which is
inherited from Value class , getMul() function return multiplication of two values which is inherited
from Value class and gitDiv() function return division of two values which Is inherited from Value
class.
Q2. Write program to create class name Area with methods name as void setRadius(float radius) and
void setLengthWidth(int len,int wid) and two child classes name as Circle and Rectangle so you have
to define float getCircleArea() method in Circle child class and calculate area of circle and return it
and You have to define getRectArea() method in Rectangle class and calculate area of rectangle and
return it
Q3. Write Program create class name as ArrSum with method void setValue(int arr[]) you have to
create child class name as GetSum with method int getArrSum() you have to accept array values
from ArrSum and calculate its sum and return it
Q4. Write program to Create class name as PersonalInfo with parameterized constructor
PersonalInfo(String name, String middlename, String lastname) and you have to create class name as
ProfessionalInfo with parameterized constructor like as ProfessionalInfo(int id,String des,int
salary,String skillset) and you have to inherit PersonalInfo class in ProfessionalInfo and pass
parameter from ProfessionalInfo class to PersonalInfo using super() constructor and you have to
define void show() method in ProfessionalInfo and you have to show the all data in show() method.
Q5. Write Program to perform method overriding you have to create class name as ArrParent with
method
void setValue(int arr[]): this method can accept array as parameter
void arrangeSeq(): this method can display array as per user input sequence
You have to create two child class name as ArrangeAscendingOrder and you have to inherit
ArrParent class in it and override arrangeSeq() method in ArrangeAscendingOrder and sort array and
display in ascending order and you have to create one more class name ReverseArray and override
arrangeSeq() method from ArrParent and reverse array and display it.
Q6. Write Program to create abstract class name as Value with one abstract and one non abstract
method
void setValue(int ,int): this is non abstract method with two parameter
abstract int getResult(): this is abstract method
and you have two child class name as Power and you have to override getResult() method in Power
class and calculate power of two values and return it as well as SearchDigit and you have to override
getResult() consider first parameter of setValue() is number and second parameter is digit and you
have to search digit in number and return it and if digit not found return -1
Q7. Write Program to create class name as ArrAbs with two methods
void setArray(int arr[],int []): this function is used for accept array as parameter
abstract int [] getResultantArray(): this function can return resultant array from different child
classes.
You have to create two classes name as InterSection you have to override getResultantArray()
method in Intersection and perform intersection of array which we pass in setArray() function and
return it as well as you have to create one more class name as Union you have to override
getResultantArray() and perform union on two array and return resultant array
Program on exception handling
1. Write a code for handle NullPointerException?
2. Write code for handle ArithmeticException?
3. Write code for handle ArrayIndexOutOfBoundsException?
4. Write code for handle StringIndexOutOfBoundsException?
5. Write code for create user defined excetion?
6. Write code using throws clause?
7. Write code for handle ClassCastException?
8. Write code for handle ClassNotFoundException?
Program on String
Q1. WAP to input string and convert lower case string to upper case without using toUpperCase()
method?
Q2. WAP to input string and reverse the string without using any inbuilt function?
Q3. WAP to input two strings and compare then without using equals() or compareTo() method ?
Q4. WAP to input string and separate digit from string and calculate its sum?
Example: abc123mno456;
Output:1+2+3+4+5+6 =15
Q5. WAP to input string and count the words from a string using split() method?
Q6. WAP to input string and input second string and search second string in first input string using
indexOf() method?
Example: First String: Good Morning India
Second string: Morning
Output: String found
Q7. WAP to input string and remove the white spaces from a string?
Q8. WAP to input string and incrypt like as?
Example: abcmnoabc
Output: a2b2c2m1n1c1
Q9. WAP to input string and reverse word from a string?
Example: good morning india
Output: doog gninrom aidni
Q10 Write a Java program to check whether a given string ends with another string.
Q11.Java Program to Find Duplicate Words in a String
Example:
Input: "This is a test. This test is easy.
Output: Duplicate words: This, is, test
Q12.Java Program to Count Occurrences of Words in a String
Example:
Input: "This is a test. This test is easy."
Output: This: 2, is: 2, a: 1, test: 2, easy: 1
Q13.Java Program to Count Vowels and Consonants in a String
Example:
Input: "Hello World"
Output: Vowels: 3, Consonants: 7
Q14.Java program to Count the Number of Duplicate Words in a String
Q15.Java Program to Remove Duplicate Words from String
Example:
Original String: Java is great and Java is fun and Java is powerful
String after removing duplicates: Java is great and fun powerful
Q16.Java Program to Reverse Each Word of a String
Example
Original String: Java is great and fun
String with each word reversed: avaJ si taerg dna nuf
Q17.How to Check if the String Contains Only Digits
Q18.Java Convert Integer to String Example
Example:
Integer value: 123
String value: 123
Q19.Write a program to count number of words in a String?
Q20.How to swap two Strings without using a third variable?
Program on Multithreading using JAVA?
1. WAP to create thread using Thread class and display value from 1 to 10 with delay 10000
milliseconds?
2. WAP to create two threads name Even and Odd and Even thread print even values between
1 to 10 and Odd thread print odd values between 1 to 10 and use join() methods as well as
perform this code using synchronization technique also.
3. WAP to print the current working thread name and its priority?
4. WAP to create thread using Runnable interface
Program on File using JAVA?
Q1. Write a program to print all drives from your system and with its total space and free space?
Q2. Write program to create folder using File class and if folder is already present then show
message folder present?
Q3. Write program to create file using File class and if file is present then show message file is exist
and if file path is not found then handle exceptions at run time?
Q4. Read all folders from Drive d: and display it?
Q5. Read all files from the D drive?
Q6. Create a file using a BufferedWriter class and store string data in it?
Q7. WAP to read file using a BufferedReader class and display it?
Q8. WAP to read file using BufferedReader and count its number of word in file, count number of
character in file and count vowels and consent from file?
Q9. WAP to read file using a BufferedReader and reverse the every word from file and store in
another file?
Q10. WAP to read file using BufferedReader class and find the words whose ending with ing word
and store in another file?
Q11. WAP to copy the image from D: drive and paste it on E drive?
Program on File using JAVA?
Q1. WAP to create Vector and store 5 values in it and fetch it using Iterator, ListIterator,
Enumeration and enhance for loop?
Q2. WAP to create Vector and store 5 values in it and arrange all values in ascending order without
using Collections.sort() method?
Q3. WAP to create Vector and store 5 values in it and find max and min value from collection
without using any inbuilt method?
Q4. WAP to create ArrayList and store 10 values in it and find occurrence of every value in ArrayList?
Q5. WAP to create LinkedList and store 10 values in it and search particular value from LinkedList?
Q6.WAP to create ArrayList and store 5 employee objects in it and display it?
Q7. WAP to create ArrayList and store 5 player detail in it with id,name and run and search player
record using its id.
Q8. WAP to create HashSet and store 10 value in it and display it
Q9. WAP to create LinkedHashSet and store 5 employee data in it and display it ?
Q10. WAP to create TreeSet and store 10 values in it and display it?