ISC 2012 Object passing program
A class Combine contains an array of integers which combines two arrays into a single array including the duplicate elements, if any, and sorts the combined array. Some of the members of the class are given below:
ISC 2012 Question 8
ISC 2020 program: Convert day number to date
A class Combine contains an array of integers which combines two arrays into a single array including the duplicate elements, if any, and sorts the combined array. Some of the members of the class are given below:
Class name: Combine
Data Members/instance variables:
com[]: integer array
size: size of the array
Member functions/methods:
Combine(int nn): parameterized constructor to assign size = nn
void inputarray(): accepts the array elements.
void sort(): sorts the elements of the combined array in ascending order using the selection sort technique.
void mix(Combine A, Combine B): combines the parameterized object arrays and stores the result in the current object array along with duplicate elements, if any.
void display(): displays the array elements.
Specify the class Combine giving details of the constructor (int), void inputarray(), void sort(), void mix (Combine, Combine) and void display (). Also, define the main() function to create an object and call the methods accordingly to enable the task.
import java.util.*;
class Combine
{
static Scanner s=new Scanner(System.in);
int com[];
int size;
Combine(int nn)
{
size=nn;
com = new int[size];
}
void inputArray()
{
System.out.println("Enter numbers"+size+"times");
for(int i=0;i<size;i++)
{
System.out.println("Enter a number");
com[i]=s.nextInt();
}
}
void Mix(Combine A,Combine B)
{
int l=A.com.length;int l1=B.com.length;
for(int i=0;i<l+l1;i++)
{
if(i<l)
com[i]=A.com[i];
else
{
com[i]=B.com[i-l];
}
}
}
void sort()
{
for(int i=0;i<com.length;i++)
{
int c=-1;
int tmp=com[i];
for(int j=i+1;j<com.length;j++)
{
if(tmp>com[j])
{
tmp=com[j];
c=j;
}
}
if(c!=-1)
{
tmp=com[i];
com[i]=com[c];
com[c]=tmp;
}
}
}
void display()
{
for(int i=0;i<size;i++)
System.out.print(com[i]+"|");
}
public static void main()
{
System.out.println("Enter size for first array");
Combine A= new Combine(s.nextInt());
A.inputArray();
System.out.println("Enter size for second array");
Combine B=new Combine(s.nextInt());
B.inputArray();
Combine o=new Combine(A.size+B.size);
o.Mix(A,B);
o.sort();
o.display();
}
}https://www.youtube.com/watch?v=zEaeCL6Hb6s
https://youtu.be/GeSDLXhzFig
Related Posts
Continue learning with these related articles

ISC Practical 2027: College Enrolment Code Validator and Stream Report – Algorithm and Java Program
Fully solved ISC Computer Science Practical 2027 question: validate college enrolment codes made of a stream, year and serial number, give the exact reason for each rejection, auto-correct lowercase streams and prepare a stream-wise report.

ISC Practical 2027: Digital Lock Security Code Analyzer – Algorithm and Java Program
Fully solved ISC Computer Science Practical 2027 number-logic question: for a 5 to 10 digit security code, find the first and last digits, odd and even position sums, product of non-zero digits, digit frequency and classify the code as STRONG, MODERATE or WEAK.

Boolean Algebra for ISC Class 12: Laws, Canonical SOP and POS, and Simplification
ISC Class 12 Computer Science notes on Boolean algebra: all the laws and theorems, duality, De Morgan's laws, minterms and maxterms, converting to canonical SOP and POS, and step-by-step algebraic simplification with solved examples.