0% found this document useful (0 votes)
17 views23 pages

ISC - Object Passing

its object passing questions

Uploaded by

mno16sep
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views23 pages

ISC - Object Passing

its object passing questions

Uploaded by

mno16sep
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

ISC Object Passing Questions

S Q Y
2020
QUESTION 9 [10]
A class Mix has been defined to mix two words, character by character, in the following manner:
The first character of the first word is followed by the first character of the second word and so on.
If the words are of different length, the remaining characters of the longer word are put at the end.
Example: If the first word is “JUMP” and the second word is “STROLL”, then the required word
will be “JSUTMRPOLL”
Some of the members of the class are as follows :
Class name : Mix
Data members/instance variables :
wrd : stores a word.
len : to store the length of the word.
Member functions/methods :
Mix( ) : default constructor to initialize data members
with legal initial values.
void feedword( ) : accepts a word in UPPER CASE.
void mix_word( Mix P, Mix Q) : mixes the words of objects P and Q as stated in
the above example and stores the resultant word
in the current object.
void displays( ) : displays the word.
Specify the class Mix giving details of the constructor( ), functions void feedword( ), void
mix_word(Mix, Mix )and void display( ). Define a main( ) function to create objects and call the
methods accordingly to enable the task.
ANSWER:
// The following program is successfully compiled and executed
import [Link].*;
class Mix
{
String wrd; int len; // declaration of string and integer data members
Mix( ) // this is default or non-parameterized constructor
{
wrd = ""; len = 0; // initializing data members
}//end of the non-parameterized constructor
void feedword( ) // function to input a word in uppercase
{ Scanner br = new Scanner( [Link] ); // creation of scanner object ‘br’
[Link]("Enter a word in UPPER CASE or CAPITAL letters = " );
wrd = br . next( ); // the function next( ) will accept only one word and ignores others
len = wrd . length( ); //finding length of the input word
}//end of the function feedword( )
void mix_word( Mix P, Mix Q ) // function to mix words stored in objects P and Q
{
int i; String newWord = ""; // integer variable and string variable to store new
word
if( P . len <= Q . len ) //checking the length of words
{
for( i = 0 ; i < P . len; i++ ) //loop up to smaller length word
{
newWord = newWord + P . wrd . charAt( i ) + Q . wrd . charAt( i ); //characters by
character mixing
}//for i loop block closes
newWord = newWord + Q . wrd . substring( i, Q . len ); //mix last characters of larger
word if any
}//end of if( ) block
else //otherwise
{
for( i = 0 ; i < Q . len; i++ ) //loop up to smaller length word
{
ISC Object Passing Questions
newWord = newWord + P . wrd . charAt( i ) + Q . wrd . charAt( i ); //characters by
character mixing
}//for i loop block closes
newWord = newWord + P . wrd . substring( i, P . len ); //mix last characters of
larger word if any
}//end of else block
wrd = newWord; //storing the mixed word in original data member ‘wrd’
}//end of the function mix_word( )
void display( ) // function to print the result
{
[Link]("The original word = " + wrd );
}//end of the function display( )
public static void main( String args[ ] ) //main function starts
{
Mix obj1 = new Mix( ); // making first object ‘obj1’ of the class
Mix obj2 = new Mix( ); // making second object ‘obj2’ of the class
Mix obj3 = new Mix( ); // making third object ‘obj3’ of the class
obj1 . feedword( ); //calling function to input first word in uppercase
obj2 . feedword( ); //calling function to input second word in uppercase
obj3 . mix_word( obj1, obj2 ); //calling function that passes words in objects ‘obj1’ & ‘obj2’
to objects P & Q
obj3 . display( ); //calling function to print mixed word
}//end of the main( ) function
}//end of the class
2019
QUESTION 8
[10]
Design a class MatRev to reverse each element of a matrix.
Example: 72 371 5 27 173 5
12 6 426 21 6 624
5 123 94 5 321 49

The details of the members of the class are given below:


Class name : MatRev
Data members/instance variables :
arr[ ][ ] : to store integer elements.
m : to store the number of rows.
n : to store number of columns.
Member functions/methods :
MatRev( int mm, int nn ) : parameterized constructor to initialize data m =
mm and n = nn.
void fillarray( ) : to enter the elements in the array.
int reverse(int x) : returns the reverse of the number x.
void revMat( MatRev P ) : reverses each element of the array of the
parameterized objectP and stores it in the array
of the current object.
void show( ) : displays the array elements in matrix form.
Specify the class MatRev giving details of the constructor, functions void fillarray( ), int
reverse(int), void revMat(MatRev) and void show( ). Define a main( ) function to create objects
and call the methods accordingly.
ANSWER :
// The following program is successfully compiled and executed
import [Link].*;
class MatRev
{
int arr[ ][ ], m, n; // declaration of double dimensional array arr[ ] and m for rows and
n for columns
ISC Object Passing Questions
MatRev( int nn, int mm ) // parameterized constructor
{
m = mm; n = nn; //initialize argument ‘mm’ to ‘m’ and ‘nn’ to ‘n’ for rowsand
columns
arr = new int[ m ][ n ]; //creation of array which is declared above with ‘m’ rows and ‘n’
columns
}//end of the parameterized constructor
void fillarray( ) // function to input integers in array arr[ ][ ] of m x n
{ Scanner sr = new Scanner( [Link] );
for( int i = 0 ; i < m ; i ++ )
{
for( int j = 0 ; j < n ; j ++ )
{
[Link]("Input number for the array = " ) ;
arr[ i ][ j ] = sr . nextInt( ); //input statement
}//closing for j loop
}//closing for i loop
}//end of the function fillarray( )
int reverse( int x ) // function to reverse the number in argument ‘x’ and return
{ int revs = 0; //variable that will store reverse number
while( x > 0 )
{
revs = revs * 10 + x % 10; //extract a digit and also reversing
x = x / 10;
}//while loop closes here
return( revs );
}//end of the function reverse( )
void revMat( MatRev P ) // function that reverses the array elements stored in Object
‘P’
{
for( int i = 0 ; i < m ; i ++ )
{
for( int j = 0 ; j < n ; j ++ )
{
arr[ i ][ j ] = reverse( P . arr[ i ][ j ]); //calling function by passing element
in Object ‘P’
}//closing for j loop
}//closing for i loop
}//end of the function revMat( )
void show( ) // function to display array in matrix form
{
for( int i = 0 ; i < m ; i ++ )
{
for( int j = 0 ; j < n ; j ++ )
{
[Link]( arr[ i ][ j ] + "\t" ) ; //print statement
}//closing for j loop
[Link]( ) ; //shifts the control to new line
}//closing for i loop
}//end of the function show( )
public static void main( String args[ ] ) //main function starts
{
MatRev obj1 = new MatRev( 3, 3 ); // making first object ‘obj1’ and passing 3 to
mm, 3 to nn
MatRev obj2 = new MatRev( 3, 3 ); // making first object ‘obj2’ and passing 3 to
mm, 3 to nn
obj1 . fillarray( ); // calling function using first object ‘obj1’ to input integers in the array
[Link]("Original Matrix : " ) ;
obj1 . show( ); // calling function using first object ‘obj1’ to display array elements in
matrix form
ISC Object Passing Questions
obj2 . revMat( obj1 ); // function call that passes array in object ‘obj1’ to the function
object ‘P’ // the current object ‘obj2’ will store Reverse of each
integer of the matrix
[Link]("Matrix after Reversing each element : " ) ;
obj2 . show( ); // calling function using 2nd/current object ‘obj2’ to display matrix with
reverse nos.
}//end of the main( ) function
}//end of the class
2018
QUESTION 8
[10]
Two matrices are said to be equal if they have the same dimension and their corresponding elements
are equal.
For example: Two matrices A and B given below are equal :
Matrix A Matrix B
1 2 3 1 2 3
2 4 5 2 4 5
3 5 6 3 5 6
Design a class EqMat to check if the two matrices are equal or not. Assume that the two matrices
have the same dimension.
Class name : EqMat
Data members/instance variables :
a[ ][ ] : to store integer elements.
m : to store the number of rows.
n : to store the number of columns.
Member functions/methods :
EqMat( int mm, int nn ) : parameterized constructor to initialize m = mm
and n = nn.
void readarray( ) : to enter the elements in the array.
int check( EqMat P, EqMat Q ) : checks if the parameterized objectsP and Q are
equal and returns 1, if true, otherwise returns
0.
void print( ) : displays the array elements in matrix form.
Specify the class EqMat giving details of the constructor, functions void readarray( ), int
check(EqMat, EqMat) and void print( ). Define the main( ) function to create objects and call the
methods to enable the task.
ANSWER :
// The following program is successfully compiled and executed
import [Link].*;
class EqMat
{
int a[ ][ ], m, n; // declaration of double dimensional array a[ ][ ] and other
required variables
EqMat( int mm, int nn ) // this is parameterized constructor
{ m = mm; n = nn; //assiging arguments ‘mm’ and ‘nn’ to data members ‘m’
and ‘n’
a = new int[ m ][ n ]; //creation of array with ‘m’ rows and ‘n’ columns
}//end of the parameterized constructor
void readarray( ) throws IOException // function to input elements in the array
{
BufferedReader br = new BufferedReader( new InputStreamReader( [Link] ));
for( int i = 0; i < m; i++ ) //this loop controls number of rows
{
for(int j = 0; j < n ; j++) //this loop controls number of columns
{
[Link]("Enter a number for the matrix = " ) ;
a[ i ][ j ] = [Link]( [Link]( ) ); //input statement
}//end of for j loop
}//end of for i loop
ISC Object Passing Questions
}//end of the function readarray( )
int check( EqMat P, EqMat Q) // function with objects ‘P’ and ‘Q’ for the class EqMat
{
for( int i = 0; i <P.m; i++ ) //this loop controls number of rows from object ‘P’
{
for(int j = 0; j <P.n ; j++) //this loop controls number of columns from object
‘P’
{
if( P.a[ i ][ j ] != Q.a[ i ][ j ]) //comparing elements of matrices from objects ‘P’
and ‘Q’
{
return 0; //returning 0 (zero) if the matrix elements are not same
}//end of if block
}//end of for j loop
}//end of for i loop
return 1; //returning 1 (one) if the above condition is never true
}//end of the function check( )
void print( ) // function to print the time in hours and minutes
{
for( int i = 0; i < m; i++ ) //this loop controls number of rows
{
for(int j = 0; j < n ; j++) //this loop controls number of columns
{
[Link]( a[ i ][ j ] + "\t" ) ; //print matrix elements
}//end of for j loop
[Link]( ) ; //shift the control to new line
}//end of for i loop
}//end of the function print( )
public static void main( String args[ ] ) throws IOException //main function starts
{
EqMat obj1 = new EqMat( 4, 4); // making first object ‘obj1’ of the class EqMat
EqMat obj2 = new EqMat( 4, 4); // making second object ‘obj2’ of the class
EqMat
obj1 . readarray( ); // calling function using first object ‘obj1’ to input matrix of 4 x 4
obj2 . readarray( ); // calling function using second object ‘obj2’ to input matrix of 4 x 4
int y = obj1 . check( obj1, obj2 ); // calling function by passing objects ‘obj1’ to function’s
object ‘P’ // and object ‘obj2’ to another object ‘Q’ with
matrices
if( y == 1) // means both the matrices are same
{
obj1 . print( ); //calling function to print matrix stored in object ‘obj1’
obj2 . print( ); //calling function to print matrix stored in object ‘obj2’
[Link]("Both the matrices are same " ) ;
}//end of if block
else // the control comes here if the function returns 0 (zero)
{
obj1 . print( ); //calling function to print matrix stored in object ‘obj1’
obj2 . print( ); //calling function to print matrix stored in object ‘obj2’
[Link]("The matrices are not same " ) ;
}//end of else block
}//end of the main( ) function
}//end of the class
2017
QUESTION 8. [10]
A class Adder has been defined to add any two accepted time.
Example: Time A = 6 hours 35 minutes
Time B = 7 hours 45 minutes
Their sum is = 14 hours 20 minutes (where 60 minutes = 1 hour)
The details of the members of the class are given below :
ISC Object Passing Questions
Class name Adder
Data members/instance variables:
a[ ] : integer array to hold two elements (hours and minutes).
Member functions/methods:
Adder( ) :
constructor to initialize 0 to the array elements.
void readtime( ) : to enter the elements of the array.
void addtime( Adder X, Adder Y ) :
adds the time of the two parameterized objects X and Y
and stores the sum of time in the current calling object.
void disptime( ) : displays the elements of the array with an appropriate
message (i.e. Hours = and Minutes = ).
Specify the class Adder giving details of the constructor, functions void readtime( ), void
addtime(Adder, Adder) and void disptime( ). Define the main( ) function to create objects and call
the methods to enable the task.
ANSWER :
// The following program is successfully compiled and executed
import [Link].*;
class Adder
{
int a[ ] = new int[ 2 ]; // declaration and creation of single dimensional array a[ ]
Adder( ) // this is non-parameterized or default constructor
{ a[ 0 ] = 0; a[ 1 ] = 0; //initialize 0 and 1 indexes of array to 0
}//end of the non-parameterized constructor
void readtime( ) throws IOException // function to input time in a[0] and a[1]
{
BufferedReader br = new BufferedReader( new InputStreamReader( [Link] ));
[Link]("Enter hours = " ) ;
a[ 0 ] = [Link]( [Link]( ) ); //input hours at a[ 0 ]
[Link]("Enter minutes = " ) ;
a[ 1 ] = [Link]( [Link]( ) ); //input minutes at a[ 1 ]
}//end of the function readtime( )
void addtime( Adder X, Adder Y) // function with objects ‘X’ and ‘Y’ with hours, minutes
{
a[ 0 ] = X . a[ 0 ] + Y . a[ 0 ]; //adding hours stored in objects ‘X’ and ‘Y’
a[ 1 ] = X . a[ 1 ] + Y . a[ 1 ]; //adding minutes stored in objects ‘X’ and ‘Y’
if( a[ 1 ] >= 60 ) //check if minutes goes beyond 60
{
a[ 0 ] = a[ 0 ] + a[ 1 ] / 60; //finding extra hours and add it to hours at array a[ 0 ]
a[ 1 ] = a[ 1 ] % 60; //finding remaining minutes and store it at a[ 1 ]
}//end of if block
}//end of the function addtime( )
void disptime( ) // function to print the time in hours and minutes
{
[Link]("Hours = " + a[ 0 ] + " and Minutes = " + a[ 1 ] ) ; // print array elements
}//end of the function disptime( )
public static void main( String args[ ] ) throws IOException //main function starts
{
Adder time1 = new Adder( ); // making first object ‘time1’ of class Adder
Adder time2 = new Adder( ); // making first object ‘time2’ of class Adder
Adder time3 = new Adder( ); // making first object ‘time3’ of class Adder
time1 . readtime( ); // calling function using first object ‘time1’ to input hours, minutes
time2 . readtime( ); // calling function using first object ‘time2’ to input hours, minutes
time3 . addtime( time1, time2 ); // calling function by passing object ‘time1’ to the
// function object ‘X’ and object ‘time2’ to the object ‘Y’
[Link]("First Time : " ) ;
time1 . disptime( ); // function call to print the time
[Link]("Second Time : " ) ;
time2 . disptime( ); // function call to print the time
[Link]("Added Time : " ) ;
time3 . disptime( ); // function call to print the time
}//end of the main( ) function
ISC Object Passing Questions
}//end of the class
2016
QUESTION 8. [10]
A class Shift contains two dimensional integer array of order (m x n) where the maximum values of
both m and n is 5. Design a class Shift to shuffle the matrix (i.e. first row becomes the last, the second
row becomes the first and so on).
The details of the members of the class are given below: :
Class name Shift
Data members/instance variables:
mat[ ][ ] : to store array elements.
m : integer to store the number of rows.
n : integer to store the number of colums.
Member functions/methods:
Merger( ) : constructor to initialize the data members.
Shift( int mm, int nn ) : parameterized constructor to initialize the data member
m=mm nd n=nn.
void input( ) : enter the elements in the array.
void cyclic( Shift P ) : enables the matrix of the object ( P ) to shift each row
upwards in a cyclic manner and store the resultant matrix
in the current object.
void display( ) : displays the elements of the array in matrix form.
Specify the class Shift giving details of the constructor, functions void input( ), void cyclic(Shift)
and void display( ). Define the main( ) function to create objects and call the methods to enable the
task of shifting the array elements.
ANSWER :
// The following program is successfully compiled and executed
import [Link].*;
class Shift
{
int mat[ ][ ]; // declaration of double dimensional array mat[ ][ ]
int m, n; // data members to store number of rows ‘m’ and number of columns ‘n’
Shift( int mm, int nn) // this is parameterized constructor
{
m = mm; n = nn; //assiging values of ‘mm’, ‘nn’ to data members ‘m’ and ‘n’
mat = new int[ m ][ n ]; //creation of double dimensional array or allocate memory to array
}//end of the parameterized constructor
void input( ) throws IOException // function to input numbers in the array mat[ ][ ]
{
BufferedReader br = new BufferedReader( new InputStreamReader( [Link] ));
for( int i = 0; i < m ; i++ )
{
for( int j = 0; j < n ; j++ )
{
[Link]("Enter a number or element for array mat[ ][ ] = " ) ;
mat[ i ][ j ] = [Link]( [Link]( ) ); //input element in the array
}// end of for ‘j’ loop
}// end of for ‘i’ loop
}//end of the function input( )
void cyclic( Shift P) // function with object ‘P’ of class ‘Shift’ as function argument
{
for( int i = 0; i < m ; i++ )
{
for( int j = 0; j < n ; j++ )
{
if( i == 0 )
mat[ m-1 ][ j ] = P. mat[ 0 ][ j ] ; // shift elements of 0th row from
else // object ‘P’ to m-1th row
mat[ i -1 ][ j ] = P. mat[ i ][ j ] ; // otherwise remaining rows in
}// end of for ‘j’ loop // cyclic manner
}// end of for ‘i’ loop
ISC Object Passing Questions
}//end of the function cyclic( )
void display( ) // function to print the elements of array mat[ ][ ] in matrix form
{
for( int i = 0; i < m ; i++ )
{
for( int j = 0; j < n ; j++ )
{
[Link]( mat[ i ][ j ] + "\t" ) ; // print elements of array
}// end of for ‘j’ loop
[Link]( ) ; // shift the control to new line
}// end of for ‘i’ loop
}//end of the function display( )
public static void main( String args[ ] ) throws IOException //main function starts
{
Shift obj1 = new Shift( 3, 3 ); // making first object ‘obj1’ of class Shift
Shift obj2 = new Shift( 3, 3 ); // making second object ‘obj2’ of class Shift
[Link]( ); // calling function using first object ‘obj1’
[Link]( ); // calling function to print the input matrix
obj2 . cyclic( obj1 ); // calling function by passing object ‘obj1’ to function object ‘P’,
// the cyclic matrix will be stored in the current object ‘obj2’
[Link]("Cyclic Matrix is : " ) ;
obj2 . display( ); // function call to print the cyclic matrix stored in the current object ‘obj2’
}//end of the main( ) function
}//end of the class
1 A class Mixer has been defined to merge two sorted integer arrays in ascending order. Some of the members 2014
of the class are given below:
Class name : Mixer
Data members /instance variables :
int arr[ ] : to store the elements of an array
int n : to store the size of the array
Member functions :
Mixer(int nn) : constructor to assign n=nn
void accept( ) : to accept the elements of the array in ascending order
without any duplicates
Mixer mix(Mixer A) : to merge the current object array elements with the
parameterized array elements and return the resultant
object
void display( ) : to display the elements of the array
Specify the class Mixer giving the details of the constructor(int), void accept( ), Mixer mix(Mixer A) and
void display( ). Define the main( ) function to create objects and call methods accordingly to enable the
task.

import [Link].*;
class Mixer
{ int n, arr[ ]; // declaration of data members ‘n’ (as size) and declaration of array arr[ ]
Mixer( int nn ) // this is parameterized constructor
{ n = nn; //assign ‘nn’ to ‘n’ as size of the array
arr=new int[ n ]; //creation of array ‘arr[ ]’ of size ‘n’
}//end of parameterized constructor
void accept( ) throws IOException //function to input numbers in the ‘arr[ ]’ upto size ‘n’
{ BufferedReader br = new BufferedReader( new InputStreamReader( [Link] ) );
[Link]("Enter "+ n+ " elements in ascending order: ");
for(int i=0; i < n; i++)
{ [Link]("Enter a number : ");
arr[ i ] = [Link]( [Link]( ) );
}//end for loop
}//end of function accept( );
Mixer mix( Mixer A) //function that takes object ‘A’ as argument and also returns object
{ int c=0;
Mixer ob = new Mixer ( n+A.n ); //object ‘ob’ of class that pass n+A.n to ‘nn’ in constructor
for(int i=0 ; i < n; i++)
{ [Link][ c++ ] = arr[ i ]; //assign numbers in the current object to new array in object ‘ob’
}
for(int j =0; j < A.n; j++)
ISC Object Passing Questions
{ [Link][ c++] = [Link][ j ]; //assign numbers in the object ‘A’ to new array in object ‘ob’
}
return ob ; //returning object ‘ob’ containing the merged array
}//end of function mix( )
void display( ) //function to print the array
{ for(int i=0; i<n; i++)
[Link]( arr[ i ] );
}//end of function display( )
public static void main( String args[ ] ) throws IOException //main function starts
{
BufferedReader bx = new BufferedReader( new InputStreamReader( [Link] ) );
[Link]("Enter the size of 1st array: ");
int s1 = [Link]( [Link]( ) );
[Link]("Enter the size of 2nd array: ");
int s2 = [Link]( [Link]( ) );
Mixer obj1 = new Mixer( s1 ); //making object 1 & pass ‘s1’ to ‘nn’ in constructor as size
Mixer obj2 = new Mixer( s2 ); //making object 2 & pass ‘s2’ to ‘nn’ in constructor as size
Mixer obj3 = new Mixer( s1+s2 ); //making object 3 & pass ‘s1+s2’ to ‘nn’ in constructor
[Link]( );
//calling function to input numbers in array ‘arr[ ]’ and store in object ‘obj1’
[Link]( ); //calling function to input numbers in array ‘arr[ ]’ and store in object ‘obj2’
obj3 = [Link]( obj2 );//calling function by pssing object ‘obj2’ to object ‘A’
// Here ‘obj1’ is current object and ‘obj3’ receives the merged array
[Link]("The numbers in the 1st array are : ");
[Link]( ); //calling function to print 1st array stored in object ‘obj1’
[Link]("The numbers in the 2nd array are : ");
[Link]( ); //calling function to print 2nd array stored in object ‘obj2’
[Link]("The numbers in the merged array are : ");
[Link]( ); //calling function to print the merged array stored in object ‘obj3’
}//end of main( ) function
}//end of class
2 A class Matrix contains a two dimensional integer array of order [m * n]. The maximum value possible for 2013
both ‘m’ and ‘n’ is 25. Design a class Matrix to find the difference of the two matrices. The details of the
members of the class are given below :
Class name : Matrix
Data members /instance variables :
arr[ ][ ] : stores the matrix element
m : integer to store the number of rows
n : integer to store the number of columns
Member functions :
Matrix(int mm, int nn) : to initialize the size of the matrix m=mm and n=nn
void fillarray( ) : to enter elements of the matrix
Matrix SubMat(Matrix A) : subtract the current object from the matrix of
parameterized object and return the resulting object
void display( ) : display the matrix elements
Specify the class Matrix giving the details of the constructor(int, int), void fillarray( ), Matrix
SubMat(Matrix A) and void display( ). Define the main( ) function to create objects and call methods
accordingly to enable the task.

import [Link].*;
class Matrix
{ int m, n; int arr[ ][ ] = new int[ 25 ][ 25 ]; //declaration of variables and array
Matrix ( int mm, int nn ) // It is parameterized constructor with arguments ‘mm’ & ‘nn’
{ m = mm; n = nn; // assign ‘mm’ to ‘m’ , ‘nn’ to ‘n’ as number of rows (m) & columns (n)
}
void fillarray( ) throws IOException // function to input a matrix of ‘m’ rows & ‘n’ columns
{ BufferedReader br = new BufferedReader( new InputStreamReader ( [Link] ));
for( int x = 0; x<m; x++ )
{ for( int y = 0; y<n; y++ )
{ [Link]( "Input a number : " );
arr[ x ][ y ] = [Link]( br. readLine( ) );
}//end of for ‘y’ loop
}//end of for ‘x’ loop
}//function fillarray( ) closes here
Matrix SubMat( Matrix A ) // function that subtract two matrices using object A
ISC Object Passing Questions
{ Matrix mat = new Matrix( m , n ); // making object of class ‘mat’ within function
for( int i = 0; i<m; i++ )
{ for( int j = 0; j<n; j++ )
{[Link][ i ][ j ]=arr[ i ][ j ] - [Link][ i ][ j ]; //subtract matrix in current object and object ‘A’
}//end of for ‘y’ loop
}//end for ‘x’ loop
return ( mat ); // returning the matrix object ‘mat’ containing the subtracted values
}//end of function SubMat( )
void display( ) // function to print the matrix of ‘m’ rows and ‘n’ columns
{for( int x = 0; x<m; x++ )
{ for( int y = 0; y<n; y++ )
{ [Link]( arr[ x ][ y ] + "\t" );
}//end of for ‘y’ loop
[Link]( );
}//end of for ‘x’ loop
}//function display( ) closes here
public static void main( String args[ ]) throws IOException // beginning of main( ) function
{ BufferedReader br = new BufferedReader(new InputStreamReader([Link]));
[Link]("Enter number of rows of matrix : " );
int row =[Link]( [Link]( ) );
[Link]("Enter number of columns of matrix : " );
int col =[Link]( [Link]( ) );
Matrix obj1=new Matrix( row, col ); //making object 1, pass ‘row’ to ‘mm’ & ‘col’ to ‘nn’
Matrix obj2=new Matrix( row, col ); //making object 2, pass ‘row’ to ‘mm’ & ‘col’ to ‘nn’
Matrix obj3=new Matrix( row, col ); //making object no 3, pass ‘row’ to ‘mm’ & ‘col’ to ‘nn’
obj1. fillarray( ); // calling function to input 1st matrix that stores in object ‘obj1’
obj2. fillarray( ); // calling function to input 2nd matrix that stores in object ‘obj2’
obj3 = [Link]( obj1 ); // calling function that passes object ‘obj1’ to object ‘A’
// and object ‘obj2’ as current object
obj3. display( ); //calling function to print the subtracted matrix stored in object ‘obj3’ }
//end of main( ) function
}
}//class clases here
3 A class Combine contains an array of integers which combines two arrays into a single array including the 2012
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 :
Combine(int nn ) : parameterized constructor to assign size = nn
void inputarray( ) : to accept the array elements
void sort( ) : sorts the elements of 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 main( ) function to create an object and
call methods accordingly to enable the task.

import [Link].*;
class Combine
{
Scanner br=new Scanner([Link]);
int arr[];
int size, i, j, k, p, t;
public Combine(int nn)
{
size=nn;
arr=new int[size];
}
public void inparr()
ISC Object Passing Questions
{
[Link]("Enter elements in an array ");
for(i=0; i<size; i++)
{
[Link]("Enter " + i + " elements in an array ");
arr[i]=[Link]();
}
}
public void mix(Combine A, Combine B)
{
k=0;
for(i=0;i<[Link];i++)
arr[k++]=[Link][i];
for(i=0;i<[Link];i++)
arr[k++]=[Link][i];
}
public void sort()
{
for(i=0;i<size;i++)
{ p=i;
for(j=i+1;j<size;j++)
if(arr[j]<arr[p]) p=j;
t=arr[i];
arr[i]=arr[p];
arr[p]=t;
}
}
public void display( )
{
[Link]("Elements in an array ");
for(i=0; i<size; i++)
[Link](arr[i]);
}
public static void main(String args[])
{
Combine obj1= new Combine(5);
Combine obj2= new Combine(5);
Combine obj3= new Combine(10);
[Link]();
[Link]();
[Link](obj1, obj2);
[Link]();
[Link]();
}
}
4 You are given a sequence of N integers, which are called as pseudo arithmetic sequences (sequences that 2011
are in arithmetic progression).
Sequence of N integers : 2, 5, 6, 8, 9, 12
We observe that 2 + 12 = 5 + 9 = 6 + 8 = 14
The sum of the above sequence can be calculated as 14 x 3 = 42.
For sequence containing an odd number of elements the rule is to double the middle element.
For example 2, 5, 7, 9, 12 = 2 + 12 = 5 + 9 = 7 + 7 = 14
14 x 3 = 42 [middle element 7]
A class Pseudoarithmetic determines whether a given sequence is a pseudo-athmetic sequence. The details
of the class are given below:
Class name : Pseudoarithmetic
Data members / instance variables :
n : to store the size of the sequence
a[ ] : integer array to store the sequence of numbers
ans, flag : store the status
sum : store the sum of sequence of numbers
r : store the sum of the two numbers
Member functions :
ISC Object Passing Questions
Pseudoarithmetic ( ) : default construtor
void accept( int nn) : to assign nn to n and to create an integer array. Fill in the
elements of the array
boolean check( ) : return true if the sequence is a pseudo-arithmetic sequence
otherwise returns false
Specify the class Pseudoarithmetic, giving details of the constructor( ), void accept( ), and boolean
check(int). Also define main( ) function to create an object and call the member functions accordingly to
enable the task.
import [Link].*;
class PseudoArithmetic
{
int n, sum, r, i, j;
boolean ans, flag;
int a[ ];
public PseudoArithmetic()
{
ans = flag = true;
sum = 0;
r = 0;
}
public void accept(int nn)
{
Scanner ob = new Scanner([Link]);
n=nn;
a = new int[n];
for(i=0; i<n; i++)
{
[Link]("Enter " + i + " element ");
a[i] = [Link]();
}
}
public boolean check()
{
r = a[0] + a[n-1];
if(n%2==0)
{
for(i=0; i<n/2; i++)
if( (a[i]+a[n-1-i]) != r)
flag = false;
}
else
{
for(j=0; j<=n/2; j++)
if( (a[j]+a[n-1-j]) != r)
ans = false;
}
if(flag==true && n%2 == 0) sum = n/2 * r;
if(ans==true && n%2 != 0) sum = (n/2 + 1)*r;
if(flag == true || ans == true) return true;
else return false;
}
public static void main(String args[])
{
int x;
Scanner ob = new Scanner([Link]);
PseudoArithmetic obj = new PseudoArithmetic();
[Link]("Enter size of sequence ");
x = [Link]();
[Link](x);
[Link]([Link]());
}
}
5 The coordinates of a point P on a two dimensional plane can be represented by P(x, y) with x as the x- 2010
coordinate and y as the y-coordinate. The coordinates of midpoint of two points P1(x1, y1) and P2(x2, y2)
can be calculated as P(x, y) where:
ISC Object Passing Questions
x = (x1 + x2) , y = (y1 + y2)
2 2
Design a class Point with the following details:
Class name : Point
Data Members/ instance variables:
x : stores the x-coordinate
y : stores the y-coordinate
Member functions:
Point( ) : constructor to initialize x = 0, y = 0
void readpoint( ) : accepts the coordinates x and y of a point
Point midpoint(Point A, Point B): calculates and returns the midpoint of the two
points A and B
void displaypoint( ) : displays the coordinates of a point
Specify the class Point giving details of the constructor( ), member functions void readpoint( ), Point
midpoint( Point, Point) and void displaypoint( ) along with the main( ) function to create an object and call
the functions accordingly to calculate the midpoint between any two given points.
import [Link].*;
class Point
{
Scanner br=new Scanner([Link]);
int x, y;
public Point()
{
x=0;
y=0;
}
public void readPoint( )
{
[Link]("Enter value of x ");
x= [Link]( );
[Link]("Enter value of y ");
y= [Link]( );
}
public void displayPoint( )
{
[Link]("Value of x is " + x);
[Link]("Value of y is " + y);
}
public Point midPoint(Point A, Point B)
{
Point D = new Point( );
D.x = (A.x + B.x)/2;
D.y = (A.y + B.y)/2;
return D;
}
public static void main(String arg[]) throws IOException
{
Point obj1= new Point();
Point obj2= new Point();
Point obj3= new Point();
[Link]();
[Link]();
[Link]();
[Link]();
[Link]("Mid Point values are ");
obj3=[Link](obj1, obj2);
[Link]();
}
}
6 A Transpose of an array is obtained by interchanging the elements of the rows and columns. 2009
A class Transarray contains a two dimensional integer array of order [m * n]. The maximum value possible
for both ‘m’ and ‘n’ is 20.
Design a class Transarray to find the transpose of a given matrix. The details of the members of the class
are given below:
ISC Object Passing Questions
Class name : Transarray
Data members/ instance variables :
arr[ ][ ] : stores the matrix elements
m : integer to store the number of rows
n : integer to store the number of columns
Member functions/methods
Transarray( ) : default constructor
Transarray( int mm, int nn ) : to initialize the size of the matrix, m=mm, n=nn.
void fillarray( ) : to enter the element of the matrix
void transpose(Transarray A) : to find the transpose of a given matrix
void disparray( ) : displays the array in a matrix form
Specify the class Transarray giving the details of the constructors, void fillarray( ), void
transpose(Transarray ) and void disparray( ). Write the main( ) function to create an object and call the
functions accordingly.

import [Link].*;
class Transarray
{
BufferedReader br=new BufferedReader(new InputStreamReader([Link]));
int arr[ ][ ]=new int [20][20];
int m, n, i, j;
public Transarray(int mm, int nn)
{ m=mm;
n=nn;
}
public void fillarray( ) throws IOException
{
[Link]("Enter " + (m*n) + " elements in an array ");
for(i=0; i<m; i++)
for(j=0; j<m; j++)
{
[Link]("Enter " + i + " " + j + " elements in an array ");
arr[i][j]=[Link]([Link]());
}
}
public void disparray()
{
for(i=0; i<m; i++)
{
for(j=0; j<m; j++)
[Link](arr[i][j] + "\t");
[Link]();
}
}
public void transpose(Transarray A)
{
for(i=0; i<m; i++)
{
for(j=0; j<m; j++)
{
arr[i][j] = [Link][j][i];
}
}
}
public static void main(String args[ ]) throws IOException
{
BufferedReader br=new BufferedReader(new InputStreamReader([Link]));
int x, y;
[Link]("Enter no. of rows in 2D Array ");
x=[Link]([Link]());
[Link]("Enter no. of columns in 2D Array ");
y=[Link]([Link]());
Transarray obj1= new Transarray(x, y);
Transarray obj2= new Transarray(y, x);
[Link]();
ISC Object Passing Questions
[Link]();
[Link]("Transpose of an array is ");
[Link](obj1);
[Link]();
}
}
7 A class Collection contains an array of 100 integers. Using the following class description create an array 2008
with common elements from two integer arrays. Some of the members of the class are given below:
Class name : Collection
Data members/ instance variables :
arr[ ] : Integer array
len : length of the array
Member functions/methods
Collection( ) : default constructor
Collection( int ) : parameterized constructor to assign the length of the array.
void inparr( ) : to accept the array elements
Collection common(Collection)
: returns a Collection containing the common elements of current
Collection object and the Collection object passed as a parameter
void arrange( ) : sort the array elements of the object containing common elements in
ascending order using any sorting technique
void display( ) : displays the array elements.
Specify the class Collection giving the details of the constructors, void inparr( ) and void arrange(),
Collection common(Collection). Write the main( ) function to create an object and call the functions
accordingly.

import [Link].*;
class Collection
{ BufferedReader br=new BufferedReader(new InputStreamReader([Link]));
int arr[]=new int[100];
int len, i, j, t;
public Collection()
{
}
public Collection(int x)
{ len=x;
}
public void inparr() throws IOException
{
[Link]("Enter elements in an array ");
for(i=0; i<len; i++)
{ [Link]("Enter " + i + " elements in an array ");
arr[i]=[Link]([Link]());
}
}
public Collection common(Collection A)
{
int l=(len<[Link])? len : [Link];
Collection B= new Collection(l);
int x=0, y=0, z=0;
while(x<len && y<[Link])
{
if(arr[x]==[Link][y])
{
[Link][z]=arr[x];
x++;
y++;
z++;
}
else if(arr[x]>[Link][y]) y++;
else x++;
}
[Link]=z;
return B;
}
ISC Object Passing Questions
public void arrange()
{
for(i=0;i<len;i++)
for(j=0;j<len-1;j++)
if(arr[j]>arr[j+1])
{
t=arr[j];
arr[j]=arr[j+1];
arr[j+1]=t;
}
}
public void disparr()
{
[Link]("Elements in an array ");
for(i=0; i<len; i++)
{
[Link](arr[i]);
}
}
public static void main(String args[]) throws IOException
{
Collection obj1= new Collection(5);
Collection obj2= new Collection(5);
Collection obj3= new Collection(10);
[Link]();
[Link]();
[Link]();
[Link]();
[Link]("Common elements of an array are ");
obj3=[Link](obj1);
[Link]();
}
}
8 There is class Ascending that contains integers that are already arranged in ascending order. Some of the 2004
member functions/methods of Ascending are given below.
Class name : Ascending
Data members/instance variables:
int al[ ] : an array of integers sorted in ascending order
int size : number of integers in the array
Members functions/methods :
Ascending(int n) : constructor to create an Ascending list of size n
void displayList( ) : to display the list of integers
Ascending merge(Ascending al)
: to merge the Ascending list al with the current Ascending list
Object and return a third Ascending list which is also sorted in
ascending order.
Important: While generating the final Ascending list both the original Ascending lists must be scanned only
once. Elements common to the two lists should appear only once in the third Ascending list.
Specify the class Ascending giving details of the functions void displayList( ) and Ascending
merge(Ascending al) only. You may assume that the other functions are written for you. You do not need to
write the main function.

import [Link].*;
class Ascending
{
Scanner br=new Scanner([Link]);
int arr[ ];
int size, i, j, k, p, len;
public Ascending(int nn)
{ size=nn;
arr=new int[size];
}
public void inparr()
{
[Link]("Enter elements in Sorted Order ");
ISC Object Passing Questions
for(i=0; i<size; i++)
{
[Link]("Enter " + i + " elements in an array ");
arr[i]=[Link]();
}
}
public Ascending merge(Ascending A)
{ len=size+[Link];
Ascending B=new Ascending(len);
i=0;
j=0;
k=0;
while(i<size && j<[Link])
{
if(arr[i]<[Link][j])
[Link][k++]=arr[i++];
else [Link][k++]=[Link][j++];
}
if(i<size)
for(p=i;p<size;p++)
[Link][k++]=arr[p];
if(j<[Link])
for(p=j;p<[Link];p++)
[Link][k++]=[Link][p];
return B;
}
public void display()
{
[Link]("Elements in an array ");
for(i=0; i<size; i++)
[Link](arr[i]);
}
public static void main(String args[])
{
Ascending obj1= new Ascending(5);
Ascending obj2= new Ascending(5);
Ascending obj3= new Ascending(10);
[Link]();
[Link]();
obj3 = [Link](obj1);
[Link]();
}
}
9 A class Date has been defined to handle Date related functions i.e. finding the future date n days after the 2003
current date ie. Date 32 days after 01 - 01 will be 02 - 02.
Finding the number of days between the current date and date on which a project ends.
Example : if a project started 01-01 and finished on 02-02, the number of days would be 32. You may assume
that all the dates are in the year 2003 only and are valid dates. To make calculations easy each date can be
converted to its equivalent date number. Date number is the number of days between 1st January (01-01) and
the given date (dd-mm).

Example: Date (dd-mm) date number


01 – 01 1
20 - 01 20
02 - 02 33
03 - 03 62
…. ….
… …..
31 - 12 365

Some of the functions/methods in Date are shown below:


Class name : Date
Data members/instance variables: dd - day
mm - month
Member functions/methods:
ISC Object Passing Questions
Date(int nd, int nm) : constructor to initialize dd=nd, mm=nm
int dateTodateNumber() : returns the dateNumber equivalent to the current Date object
Date dateNumberToDate(int dn) : returns the Date equivalent to the given dateNumber dn
Date futureDate(int n) : returns the Date that occurs n days after the current Date object.
You may assume that the future date will be in the year 2003 only.
Specify the class Date giving the details of the constructor Date(int nd, int nm), int dateTodateNumber(),
Date dateNumberToDate(int dn), Date futureDate(int n). You may assume that the other functions /
methods are written for you.

import [Link].*;
class Date
{
int dd,mm;
int daysInAMonth[ ]={ 31,28,31,30,31,30,31,31,30,31,30,31};
public Date(int d,int m)
{ dd=d;
mm=m;
}
int dateToDateNumber()
{
int dateNum = dd;
for(int i = 0; i<mm-1; i++)
dateNum + = daysInAMonth[i];
return(dateNum);
}
Date dateNumberToDate(int dn)
{
int m =1;
while(dn>daysInAMonth[m-1])
{ dn=dn-daysInAMonth[m-1];
m++;
}
int d=dn;
Date dat=new Date(d,m);
return dat;
}
Date futureDate(int n)
{ int fDateNum=n+dateToDateNumber( );
return dateNumberToDate(fDateNum);
}
int noOfDays(Date endDate)
{
int diff=[Link]() - dateToDateNumber();
return diff;
}
public static void main(String arg[ ]) throws IOException
{
DataInputStream ob = new DataInputStream([Link]);
int d1,m1,dd=0,mm=0;
[Link]("Enter day and month as starting date");
d1=[Link]([Link]());
m1=[Link]([Link]());
Date date1= new Date(d1,m1);
Date dd1=new Date(dd,mm);
[Link]("Enter no of days to calculate future date ");
int n1;
n1=[Link]([Link]());
dd1=[Link](n1);
[Link]([Link] + "\t" + [Link]);
}
}
10 A set is a collection in which there is no duplication of elements. S = { 1, 6, 9, 24 } is a set of 4 integer 2003
elements. An array of integers may be used to represent a set. You may assume that there will a maximum
of 50 elements in the set.
ISC Object Passing Questions
Following are some member functions of the class Set
Class name : Set
Data members/instance variables:
arr - an array of integers to store the elements of the set
n - an integer to store the total number of elements in the set
Member functions/methods:
Set(int nn) : constructor to initialize n=nn and the array arr
void readElements() : reads the elements of the set
void displayElements() : displays the elements of the set
int getSize() : returns n, the number of elements in the set
int has(int ele) : returns 1 if ele belongs to the current set object and 0 otherwise
Set intersection(Set d) : returns the intersection of set object d and the current set object
i.e. the set containing the elements that are common to both the sets

Set unions(Set d) : returns the union of set object d and the current set object i.e.
the set containing the elements that are present in both the sets
Specify the class Set giving the details of the functions int has(int ele), Set intersection( Set d), Set
union( Set d). You may assume that the other functions/methods are written for you.

import [Link].*;
class Set
{
int arr[ ]=new int[50];
int n, i, j;
DataInputStream obj=new DataInputStream([Link]);
Set(int nn)
{
n=nn;
for(int i=0;i<n;i++)
arr[i]=0;
}
void readElements( ) throws IOException
{
[Link]("ENTER THE ELEMENTS OF THE ARRAY:");
for(i=0;i<n;i++)
{
[Link]("ENTER THE " + i + " ELEMENTS :");
arr[i]=[Link]([Link]());
}
}
void displayElements( )
{
for(i=0;i<n;i++)
[Link](arr[i]+"\t");
}
int getsize() throws IOException
{
[Link]("ENTER THE NUMBER OF ELEMENTS:");
n=[Link]([Link]());
return n;
}
int has(int ele)
{
int ans=0;
for(i=0;i<n;i++)
if(ele==arr[i])
{
ans=1;
break;
}
return ans;
}

Set intersection(Set d) throws IOException


{
ISC Object Passing Questions
int sz;
if(d.n<n) sz=d.n;
else sz=n;
Set s=new Set(sz);
int ind=0;
for(i=0;i<n;i++)
if([Link](arr[i])==1)
{ [Link][ind]=arr[i];
ind++;
}
s.n=ind;
return s;
}
Set unions(Set d) throws IOException
{
int sz=n+d.n;
Set s=new Set(sz);
int ind=0;
for(i=0;i<d.n;i++)
{
[Link][ind]=[Link][i];
ind++;
}
for(i=0;i<n;i++)
if([Link](arr[i])==0)
{ [Link][ind]=arr[i];
ind++;
}
s.n=ind;
return s;
}
public static void main(String args[]) throws IOException
{
Set q=new Set(50);
Set a=new Set([Link]());
[Link]();
Set b=new Set([Link]());
[Link]();
Set c=new Set(50);
[Link]("THE INTERSECTION ELEMENTS ARE:");
c=[Link](b);
[Link]();
[Link]();
[Link]("THE UNIONS ELEMENTS ARE:");
c=[Link](b);
[Link]();
}
}
11 A manager of an Internet Service Provider company wants to analyze the system usage from the log records 2002
to find the utilization of the system. He wants to know:
For how long did each user use the system?
When the user wants to use the system he must login to the system(starttime e.g. 12:30) and after finishing
the work he must logout off the system(endtime e.g. 18:10).
The time format is the 24-hour system hours and minutes. You may also assume that the data is valid and a
user will login for less than 24 hours. You may assume that a user will login once in 24 hours. If
endtime(e.g. 2:30) is less than the starttime(e.g. 19:20) it means that user logged in over the night.

A class Time has been defined to calculate the time related functions. Some of the functions/ methods in
Time are shown below:
Class name : Time
Data members/instance variables: hh - hours
mm - minutes
Member functions/methods:
Time( ) : constructor
void readtime( ) : to read time in 24 hour mode as hh mm
ISC Object Passing Questions
void disptimeansi( ) : to display time in 24 hour mode as hh mm
int timetominutes(time) : to find total number of minutes in hh mm
void minutestotime(int) : to convert total number of minutes into hh mm
void diff(time endtime, time starttime)
: to find the difference between endtime and starttime in
hours and minutes
Specify the class Time giving the details of the constructor, int timetominutes(time), void
minutestotime(int), void diff(time endtime, time starttime) only. You may assume that the other
functions are written for you.

import [Link].*;
class time
{
DataInputStream ab = new DataInputStream([Link]);
public int hh,mm;
public time()
{ hh=0;
mm=0;
}
public void readtime() throws IOException
{
do {
[Link]("\n Enter hours in 24 Hours format ");
hh=[Link]([Link]());
} while(hh<0 || hh>23);
do {
[Link]("\n Enter minutes ");
mm=[Link]([Link]());
} while(mm<0 || mm>59);
}

public void disptimeansi()


{
[Link]("\n Hours " + hh + " minutes " + mm);
}
public int timetominutes(time t)
{ int mins;
mins=[Link]*60 + [Link];
return mins;
}
public void minutestotime(int mins)
{
mm=mins%60;
hh=mins/60;
}
void diff(time start, time end)
{
int diffm, x, y;
x=timetominutes(start);
y=timetominutes(end);
if(y<x) y=y+24*60;
diffm=y-x;
minutestotime(diffm);
}
public static void main(String arg[]) throws IOException
{
time t1=new time();
time t2=new time();
time t3=new time();
[Link]("\n Enter the starting time ");
[Link]();
[Link]();
[Link]("\n Enter the ending time ");
[Link]();
ISC Object Passing Questions
[Link]();
[Link](t1,t2);
[Link]("\n Difference between the two times is :");
[Link]();
}
}
12 An angle can be measured in degrees and minutes e.g. 2001
Angle A = 70 degrees 35 minutes and Angle B = 50 degrees 40 minutes
Now find the sum of these two angles:
Angle C = Angle A + Angle B
= 70 degrees 35 minutes + 50 degrees 40 minutes
= 121 degrees 15 minutes ( Since 1 degree = 60 minutes )
A class called Angle has been defined to calculate the Angle related functions. Some of the functions/
methods in Angle are shown below:
Class name : Angle
Data members/instance variables: dd - degrees
mm - minutes
Member functions/methods:
Angle( ) constructor
void readAngle( ) to read Angle as dd mm
void dispAngle( ) to display Angle as dd mm
void sumAngle( Angle A, Angle B) to find the sum of two angles A and B
void diffAngle( Angle A, Angle B) to find the difference between angle A and B
in degrees and minutes
Specify the class Angle giving details of the constructor, void sumAngle( Angle A , Angle B ), void
diffAngle( Angle A, Angle B) only. You may assume that the other functions are written for you.

import [Link].*;
class Angle
{
Scanner br=new Scanner([Link]);
int deg, min;
public Angle( )
{
deg = 0;
min = 0;
}
public void readAngle()
{
[Link]("Enter degree ");
deg=[Link]();
[Link]("Enter minutes");
min=[Link]();
}
public void sumAngle(Angle A, Angle B)
{
deg = [Link] + [Link];
min = [Link] + [Link];
if(min>60)
{
deg = deg + 1;
min = min - 60;
}
}
public void diffAngle(Angle A, Angle B)
{
int z;
int x = [Link] * 60 + [Link];
int y = [Link] * 60 + [Link];
if(x>y) z = x - y;
else z = y - x;
deg = z / 60;
min = z % 60;
}
public void dispAngle()
ISC Object Passing Questions
{
[Link]("Angle in degree is = " + deg );
[Link]("Angle in minutes is = " + min );

}
public static void main(String args[])
{
Angle obj1= new Angle();
Angle obj2= new Angle();
Angle obj3= new Angle();
[Link]();
[Link]();
[Link]("Sum of two angle is : ");
[Link](obj1, obj2);
[Link]();
[Link]("Difference of two angle is : ");
[Link](obj1, obj2);
[Link]();
}
}

You might also like