CS-4004 Event Driven Programming
Que - 1: Enlist the types of Programming language and describe in brief. Enlist
any six advantages of Object-Oriented Programming Language.
Ans: Types of programming language are as follows:
Procedural Programming Language
Functional Programming Language
Scripting Programming Language
Logic Programming Language
Object-Oriented Programming Language
Advantages of Object-Oriented Programming Language are as follows:
We can build the programs from standard working modules that
communicate with one another, rather than having to start writing
the code from scratch which leads to saving of development time
and higher productivity,
OOP language allows to break the program into the bit-sized
problems that can be solved easily (one object at a time).
The new technology promises greater programmer productivity,
better quality of software and lesser maintenance cost.
OOP systems can be easily upgraded from small to large systems.
It is possible that multiple instances of objects co-exist without any
interference,
It is very easy to partition the work in a project based on objects.
It is possible to map the objects in problem domain to those in the
program.
The principle of data hiding helps the programmer to build secure
programs which cannot be invaded by the code in other parts of the
program.
By using inheritance, we can eliminate redundant code and extend
the use of existing classes.
Que - 2: Implement the below-given programs in an object-oriented language.
1. Consider two arrays A and B which will have five integer numbers in each.
Create another array C which will have ten integer numbers from both A
and B as appended values. Show values of C in sorted order.
Ans: class FindAppend {
static int printAppend(int arr1[], int arr2[], int m, int n)
{
int i = 0, j = 0;
while (i < m && j < n) {
if (arr1[i] < arr2[j])
System.out.print(arr1[i++] + " ");
else if (arr2[j] < arr1[i])
System.out.print(arr2[j++] + " ");
else {
System.out.print(arr2[j++] + " ");
i++;
}
}
while (i < m)
System.out.print(arr1[i++] + " ");
while (j < n)
System.out.print(arr2[j++] + " ");
return 0;
}
public static void main(String args[])
{
int arr1[] = { 1, 2, 4, 5, 6 };
int arr2[] = { 2, 3, 5, 7 };
int m = arr1.length;
int n = arr2.length;
printAppend(arr1, arr2, m, n);
}
}