FUNCTION OVERLOADING
Function overloading is process of defining two or more methods/Functions with same
function names but different data types/order/number of parameters must be different.
Polymorphism is the process to define more than one body for functions/ methods with
same name. Overloading is a type of polymorphism, where the signature part must
be different.
Examples with no return value
• void calculate( int a)
• void calculate( int a, int b)
• void calculate ( float a , float b )
• void calculate( int a, float b, char ch)
• void calculate( float x , float y, int z)
• void calculate( int x, int y)
invalid because void calculate( int a , int b) have same signature.( same data types and
number of parameters ) i.e 2nd and 6th examples are same
Examples with return value
int calculate( int a)
int calculate( int a, int b)
char calculate( int a, float b char ch)
float calculate( float x , float y, int z)
Q1. Write function prototype add which accepts 2 integer values and returns none
Ans void add (int a, int b)
Q2. Write function prototype cal which accepts 2 integer, one double value and one
character
value and returns none.
Ans void cal( int a , int b , double c, char ch)
Q3. Write function prototype compute which accepts 2 string values, 2 integer values and
returns 0 or 1 .
Ans int compute( String st1, String st2 , int a , int b )
Q4. Write function prototype process which accepts 2 boolean values and 2 string values
returns None
Ans void process ( boolean b1, boolean b2 , String st1 , String st2 )
Q5. Write function prototype input which accepts 2 long values, 2 character value and one
String value and returns character value .
Ans char input( long a , long b , char ch1 , char ch2 , String st )
Programs Example with no return value
Q1. WP to find sum of 2 numbers and sum of 3 number using Function Overloading.
import [Link].*
public class Addition
{
void sum(int num1,int num2)
{
int s ;
s = num1 + num2;
[Link]( “ Sum Of Two Numbers = “ + s );
}
void sum(int num1,int num2, int num3)
{
int s ;
s = num1 + num2 + num3;
[Link](“Sum Of Three Numbers = “ + s );
}
public static void main( )
{
Scanner sc = new Scanner([Link]) ;
Addition ob = new Addition();
[Link](20, 15);
[Link](20, 100, 10);
} // public
} // class
Q2. WP to find Sum of 2 numbers, Difference of two numbers, product of two numbers
using function Overloading . Accept the data from user .
import [Link].*
public class Compute
{
void process(int num1, int num2)
{
int s ;
s = num1 + num2;
[Link]( “ Sum Of Two Numbers = “ + s );
}
void process(float num1, float num2)
{
float d ;
d = num1 - num2;
[Link]( “ Difference Of Two Numbers = “ + d );
}
void process(long num1, long num2)
{
long p;
p = num1 * num2;
[Link]( “Product Of Two Numbers = “ + p );
}
public static void main( )
{
Scanner sc = new Scanner([Link]) ;
Compute ob = new Compute();
int a, b ;
float a1, b1;
long a2 , b2 ;
[Link](“Enter 2 Numbers “ );
a = [Link]() ;
b = [Link]() ;
[Link](“Enter 2 Numbers “ );
a1 = [Link]() ;
b1 = [Link]() ;
[Link](“Enter 2 Numbers “);
a2 = [Link]() ;
b2= [Link]() ;
[Link](a , b);
[Link](a1 ,b1);
[Link](a2, b2);
} // public
} //class
Q3. Write a to find the areas for the following geometric figures using function
overloading.
• Area of triangle (at = bh/2)
• Area of circle (ac = 22/7 r2 )
• Area of Square ( as = s2 )
import [Link].*;
public class Over_loading
{
void area( int b, int h)
{
float at;
at = (float) b *h / 2 ;
[Link]("Area Of Triangle “ + at);
}
void area(float r )
{
float ac;
ac = r * r * 22/7 ;
[Link]("Area Of Circle “ + ac);
}
void area( int s)
{
int as ;
as = s* s;
[Link]("Area Of Square “ + as);
}
public static void main( )
{
Scanner sc =new Scanner([Link]);
int b1, h1 ,s1 , ch ;
float r1;
Over_loading ob =new Over_loading();
[Link]("Enter Triangle Base ");
b1=[Link]();
[Link]("Enter Triangle Height ");
h1=[Link]();
[Link]("Enter Circle Radius");
r1=[Link]();
[Link]("Enter Square Side ");
s1=[Link]();
[Link](b1 , h1);
[Link]( r1);
[Link](s1);
} // main
} // class
Q4. Write a Menu program to find the areas for the following geometric figures using
function overloading.
MENU
• Area of triangle
• Area of circle
• Area of Square
Enter Your Choice [ 1, 2 ,3 ]
• Area of triangle (at = bh/2)
• Area of circle (ac = 22/7 r2 )
• Area of Square ( as = s2 )
import [Link].*;
public class Over_loading
{
void area( int b, int h)
{
float at;
at = (float) b *h / 2 ;
[Link]("Area Of Triangle “ + at);
}
void area(float r )
{
float ac;
ac = r * r * 22/7 ;
[Link]("Area Of Circle “ + ac);
}
void area( int s)
{
int as ;
as = s* s;
[Link]("Area Of Square “ + as);
}
public static void main( )
{
Scanner sc =new Scanner([Link]);
int b1, h1 ,s1 , ch ;
float r1;
[Link](" \t\t\t\t MENU\n\n ");
[Link]("\t\t 1. Area Of Triangle ");
[Link]("\t\t 2. Area Of Circle ");
[Link]("\t\t 3. Area Of Square ");
[Link]("Enter Your Choice [1 , 2 , 3 ] \n\n");
ch = [Link]();
Over_loading ob =new Over_loading();
switch(ch)
{
case 1 : [Link]("Enter Triangle Base ");
b1=[Link]();
[Link]("Enter Triangle Height ");
h1=[Link]();
[Link](b1 , h1);
break ;
case 2 : [Link]("Enter Circle Radius");
r1=[Link]();
[Link]( r1);
break;
case 3 : [Link]("Enter Square Side ");
s1=[Link]();
[Link](s1);
break;
default : [Link]("Wrong choice");
} // End Of Switch Statement
} // public
} // class
Q5. Write a program to find the areas for the following geometric figures using function
overloading and return statement.
• Area of triangle (at = bh/2)
• Area of circle (ac = 22/7 r2 )
• Area of Square ( as = s2 )
import [Link].*;
public class Over_loading
{
float area( int b, int h)
{
float at;
at = (float) b *h / 2 ;
return at ;
}
float area(float r )
{
float ac;
ac = r * r * 22/7 ;
return ac ;
}
int area( int s)
{
int as ;
as = s* s;
return as ;
}
public static void main( )
{
Scanner sc =new Scanner([Link]);
int num , b1, h1 ,s1,as1 ;
float r1 ,at1 ,ac1 ;
[Link](" \t\t\t\t MENU ");
[Link]("\t\t 1. Area Of Triangle ");
[Link]("\t\t 2. Area Of Circle ");
[Link]("\t\t 3. Area Of Square ");
[Link]("Enter Your Choice 1 to 3");
num=[Link]();
Over_loading ob =new Over_loading();
switch(num)
{
case 1 : [Link]("Enter Triangle Base ");
b1=[Link]();
[Link]("Enter Triangle Height ");
h1=[Link]();
at1 = [Link](b1 , h1);
[Link]("Area Of Triangle “ + at);
break ;
case 2 : [Link]("Enter Circle Radius")
r1=[Link]();
ar1 =[Link]( r1);
[Link]("Area Of Circle “ + ac1);
break;
case 3 : [Link]("Enter Square Side ");
s1=[Link]();
as1 =[Link](s1);
[Link]("Area Of Square “ + as1);
break;
default t : [Link]("Wrong choice");
} // End Of Switch Statement
} // public
} // class
Q6) WP to find sum of 2 numbers and sum of 3 number using Function Overloading
using return statement.
import [Link].*;
public class Addition
{
int sum(int num1,int num2)
{
int s ;
s = num1 + num2;
return s;
}
int sum(int num1,int num2, int num3)
{
int s ;
s = num1 + num2 + num3;
return s;
}
public static void main( )
{
Scanner sc = new Scanner([Link]) ;
{
Addition ob = new Addition();
int s1, s2 ;
s1 = [Link](20, 15);
s2 = [Link](80, 100, 10);
[Link]( “ Sum Of Two Numbers = “ + s1 );
[Link]( “ Sum Of Three Numbers = “ + s2 );
} // main
} // class
Q7) Wp to find sum, difference,product and division of 2 numbers using function
overloading and using return statement.
import [Link].*
public class Compute
{
int process(int num1, int num2)
{
int s ;
s = num1 + num2;
return s;
}
float process(float num1, float num2)
{
float d ;
d = num1 - num2;
return d;
}
long process(long num1, long num2)
{
long p;
p = num1 * num2;
return p ;
}
double process(double num1, double num2)
{
double dv ;
dv = num1 / num2 ;
return dv ;
}
public static void main( )
{
Scanner sc = new Scanner([Link]) ;
Compute ob = new Compute();
int a, b ,s1 ;
float a1, b1 ,d1 ;
long a2 , b2 ,p1 ;
double a3, b3 , dv1 ;
[Link](“Enter 2 Numbers “);
a = [Link]() ;
b = [Link]() ;
[Link](“Enter 2 Numbers “);
a1 = [Link]() ;
b1 = [Link]() ;
[Link](“Enter 2 Numbers “);
a2 = [Link]() ;
b2= [Link]() ;
[Link](“Enter 2 Numbers “);
a3 = [Link]() ;
b3= [Link]() ;
s1 = [Link](a , b);
d1 = [Link](a1 ,b1);
p1 = [Link](a2, b2);
dv1 = [Link](a3, b3);
[Link]( “ Sum Of Two Numbers = “ + s1 );
[Link]( “ Difference Of Two Numbers = “ + d1 );
[Link]( “Product Of Two Numbers = “ + p1 );
[Link]( “Division Of Two Numbers = “ + dv1 );
} // main
} //class
Q8) WP to input a number. Use a function int Armstrong(int n) to accept the number. The
function returns 1 if the number is an Armstrong otherwise it returns 0.
import [Link].*
public class Number
{
int Armstrong( int n)
{
int m , copy ;
s = 0;
copy = n;
while(copy >0)
{
m= copy % 10;
s=s +m*m*m;
copy = copy /10;
} // while
if( n == s)
return 1 ;
else
return 0;
}
public static void main ( )
{
Scanner sc = new Scanner ( [Link]);
int num , a ;
[Link]("Enter Any Number “ );
num=[Link]();
Number ob = new Number();
a = [Link]( num ) ;
If (a == 1)
[Link](num +” Is An Armstrong Number “);
else
[Link](num +” Is Not A Armstrong Number “);
} // main
} //class
Q9) WP to input a number. Use a function int Palindrome(int n) to accept the number. The
function returns reverse number to main program and check number is a Palindrome or
not.
public class Number
{
int Palindrome( int n)
{
int m , copy , rev;
rev = 0;
copy = n;
while(copy >0)
{
m= copy % 10;
rev = rev * 10 + m ;
copy = copy /10;
} // while
return rev ;
}
public static void main( )
{
Scanner sc = new Scanner ( [Link]);
int num , r ;
[Link]("Enter Any Number “ );
num=[Link]();
Number ob = new Number();
r = [Link]( num ) ;
If (num == r)
[Link](num +” Is An Palindrome Number “);
else
[Link](num +” Is Not A Palindrome Number “);
} // main
} //class
Q10) WP to input a number. Use a function int Pronic(int n) to accept the number. The
function returns 1 if the number is Pronic else returns 0.
Ex : 12 = 3 * 4 , 20 = 4 * 5 , 42 = 6 * 7 are Pronic numbers
import [Link].*
public class Number
{
int Pronic( int n)
{
int i , p ;
for( i = 1 ; i < n; i++ )
{
p = i * ( i + 1) ;
if( n == p)
return 1 ;
} // for
return 0;
}
public static void main ( )
{
Scanner sc = new Scanner ( [Link]);
int num , p ;
[Link]("Enter Any Number “ );
num=[Link]();
Number ob = new Number();
p = [Link]( num ) ;
If ( p == 1)
[Link](num +” Is A Pronic Number “);
else
[Link](num +” Is Not A Pronic Number “);
} // main
} //class
Q11)
class Overload
{
double series( double n )
{
int i ;
double sum = 0 ;
for( i=1;i<=n ; i++)
sum = sum + (double ) 1 / i ;
return sum;
}
double series( double a , double n )
{
int i , p = 1 , p1 =2 ;
double sum= 0;
for( i=1;i<=n ; i++)
{
sum = sum + (double )p/ [Link](a , p1 );
p = p +3;
p1 = p1 + 3;
}
return sum ;
} // I loop
}
public static void main( )
{
Scanner sc =new Scanner([Link]);
double n1,a1 ,s1, s2;
[Link](“ Enter Number Of Terms “);
n1 = [Link]();
[Link](“Enter Value For A“);
a1 = [Link]();
Overload ob = new Overload();
s1 = [Link](n1 );
s2 = [Link](a1 , n1 );
[Link](“ Sum = “ + s1 );
[Link](“ Sum = “ + s2 );
} // main
} // class
Q12)
class Overload
{
void polygon( int n , char ch )
{
int i , j ;
for( i=1;i<=n ; i++)
{
for( j=1;j<=n; j++)
{
[Link](ch );
} // j loop
[Link]();
} // I loop
}
void polygon( int x , int y )
{
int i , j ;
for( i=1;i<=x ; i++)
{
for( j=1;j<=y ; j++)
{
[Link](“@” );
} // j loop
[Link]();
} // I loop
}
void polygon( )
{
int i , j ;
for( i=1;i<=3 ; i++)
{
for( j=1;j<=i ; j++)
{
[Link](“*” );
} // j loop
[Link]();
} // I loop
}
public static void main( )
{
Scanner sc =new Scanner([Link]);
int n1 , x1, y1 ;
char ch1 ;
[Link](“ Enter Three Numbers “);
n1 = [Link]();
x1 = [Link]();
y1 = [Link]();
[Link](“Enter Character “);
ch1 = [Link]().charAt(0);
Overload ob = new Overload();
[Link](n1 ,ch1 );
[Link](x1 , y1 );
[Link]( );
} // main
} // class
Q13. Create overloaded methods named void calc_volume ( ), that has been overloaded to
perform the following functions
• Volume of Sphere v= 4/3 22/7 r3
• Volume of Cylinder v = 22/7 r2 h
• Volume of Cone v = 22/7 r2 h/3
Write a menu driven program in Java to display the above 3 menus and execute the
overloaded methods and display the volume in the respective functions,
calc_volume (double) for sphere,
calc_volume (double, double) for cylinder and
calc_volume (float, float) for cone.
import [Link].*;
public class Over_loading
{
double volume( double r)
{
double vs ;
Vs = 4/3 * 22/7 * r * r * r ;
return vs;
}
double volume( double r , double h)
{
double vc ;
Vs = 22/7 * r * r * h ;
return vc;
}
double volume( float r , float h)
{
double vc ;
Vs = 22/7 * r * r * h/3 ;
return vc ;
}
public static void main()
{
Scanner sc =new Scanner([Link]);
int num ;
double vs1, vc1 , vco, r1 ,h1 ;
float r2, h2 ;
[Link]("\t\t\t\t Menu \n\n”) ;
[Link]("\t\t 1. Volume Of Sphere “);
[Link]("\t\t 2. Volume Of Cylinder “);
[Link]("\t\t 3. Volume Of Cone “);
[Link]("Enter any from 1 to 3");
num=[Link]();
Over_loading ob =new Over_loading();
switch(num)
{
case 1:
{
[Link]("Enter radius of Sphere");
r1=[Link]();
vs1=[Link](r1);
[Link]("Volume of a Sphere is"+vs1);
break;
}
case 2:
{
[Link]("Enter radius and heigth of a Cylinder");
rl=[Link]();
h1=[Link]();
vc1 =[Link](r1, h1);
[Link]("Volume of a cylinder is"+vc1);
break;
}
case 3:
{
[Link]("Enter radius and heigth of a Cone");
r2=[Link]();
h2=[Link]();
vco =[Link](r1, h1);
[Link]("Volume of a cone is"+vco);
break;
}
default:
[Link]("Wrong choice");
} // switch
} // main
} // class
Q14) Write a class program to design a calculator with the following specification:
Class name: Calculator
Data member/instant variable: private int result
Member functions –
Calculator ( ) : constructor to initialized result with zero.
void add(int a) : to add a with the result
void sum(int a) : to subtract a from the result
void mul( ) : to multiply result
void div( ) : to divide result by a
void display( ) : to display result
void clear( ) : to clear the result
Q15) Write a class program with the following specifications:
Class name : factorial
Data members : int a
Member function :
Factorial( ) : default constructor to initialize the data member.
void input (int m) : to assign a with m
void display( ) : to print factorial of the number.
Q16) Write a program in java to accept a number and check whether it is a weakarm No. or
not
[135 is a weakarm no. because 135 = 11+32+53]
Q17) pg 315/ 25
class Overload
{
void display( String str, char ch)
{
char ch1 , ch2 ;
int l ;
ch1 = [Link](0);
l = [Link]() – 1 ;
ch2 = [Link](l);
if(ch1 == ch && ch2 == ch)
[Link](str + “Is A Special Word “);
else
[Link](str + “Is Not A Special Word “);
}
void display( String str1, String str2)
{
if([Link](str2))
[Link](str1 + “ , “ + str2 + “ Two Strings Are Equal “);
else
[Link](str1 + “ , “ + str2 + “ Two Strings Are Not Equal “);
}
void display( String str , int n)
{
char ch ;
ch = [Link](n-1);
[Link](“ Character Is “ + ch) ;
}
public static void main( )
{
Scanner sc =new Scanner([Link]);
String st1, st2 ;
int n ;
char ch ;
[Link](“ Enter Two Strings “);
st1 = [Link]();
st2 = [Link]();
[Link](“ Enter Position Of The Character “);
n = [Link]();
[Link](“Enter Any Character “);
ch = [Link]().charAt(0);
Overload ob = new Overload();
[Link](st1 , ch );
[Link](st1 , st2 );
[Link](st1 , n );
} // main
} // class
Q18) pg 314/ 21
class Overload
{
void compare( int n1 , int n2 )
{
if(n1 > n2 )
[Link](n1 + “Is Greatest Number “);
else
[Link](n2 + “Is Greatest Number “);
}
void compare( char ch1 , char ch2 )
{
if( ch1> ch2 )
[Link]( “ Highest Numeric Value Is “ + int(ch1));
else
[Link]( “ Highest Numeric Value Is “ + int(ch2));
}
void compare( String s1 , String s2)
{
int l1 , l2 ;
l1 = [Link]();
l2 = [Link]();
if(l1 > l2 )
[Link](s1 + “Is The Longest String “);
else
[Link](s2 + “Is The Longest String “);
}
public static void main()
{
Scanner sc =new Scanner([Link]);
String st1, st2 ;
int n1 , n2 ;
char c1 , c2 ;
[Link](“ Enter Two Strings “);
st1 = [Link]();
st2 = [Link]();
[Link](“ Enter Two Numbers “);
n1 = [Link]();
n2 = [Link]();
[Link](“Enter Two Characters “);
c1 = [Link]().charAt(0);
c2 = [Link]().charAt(0);
Overload ob = new Overload();
[Link](n1 , n2 );
[Link](c1 , c2 );
[Link](st1 ,st2 );
} // main
} // class
Q19) 22/314
class Overload
{
void polygon( int n , char ch )
{
int i , j ;
for( i=1;i<=n ; i++)
{
for( j=1;j<=n; j++)
{
[Link](ch );
} // j loop
[Link]();
} // I loop
}
void polygon( int x , int y )
{
int i , j ;
for( i=1;i<=x ; i++)
{
for( j=1;j<=y ; j++)
{
[Link](“@” );
} // j loop
[Link]();
} // I loop
}
void polygon( )
{
int i , j ;
for( i=1;i<=3 ; i++)
{
for( j=1;j<=i ; j++)
{
[Link](“*” );
} // j loop
[Link]();
} // I loop
}
public static void main( )
{
Scanner sc =new Scanner([Link]);
int n1 , x1, y1 ;
char ch1 ;
[Link](“ Enter Three Numbers “);
n1 = [Link]();
x1 = [Link]();
y1 = [Link]();
[Link](“Enter Character “);
ch1 = [Link]().charAt(0);
Overload ob = new Overload();
[Link](n1 ,ch1 );
[Link](x1 , y1 );
[Link]( );
} // main
} // class
Q20 ) Pg 313/ 17
class Overload
{
void display( String str, int p)
{
char ch ;
int i , l ;
l = [Link]() ;
for( i =0 ; i< l : i++ )
{
ch = [Link](i);
if(p == 1)
{
If([Link](ch))
[Link](ch + “ “);
}
else
[Link]( ch + “ “);
} // for
}
void display( String str , char chr )
{
char ch ;
int i , l ;
l = [Link]() ;
for( i =0 ; i< l : i++ )
{
ch = [Link](i);
if(chr == ‘v’)
{
If(ch == ‘A’ || ch == ‘a’ || ch == ‘E’ || ch ==’e’ || ch==’I’ || ch==’i’ || ch == ‘O’ || ch==’o’ || ch ==
‘U’
|| ch ==’u’))
[Link](ch + “ “);
}
else
{
If([Link](ch))
[Link]( ch + “ “);
}
} //for
}
public static void main( )
{
Scanner sc =new Scanner([Link]);
String st1 ;
int p1;
char ch1;
[Link](“ Enter String “);
st1 = [Link]();
[Link](“Enter Position “);
p1 = [Link]();
[Link](“Enter Character “);
ch1 = [Link]().charAt(0);;
Overload ob = new Overload();
[Link](st1 , p1 );
[Link](st1 , ch1 );
} // main
} // class
Q21)
class Overload
{
void manip ( String str , int p )
{
int i , l ;
char ch ;
l =[Link]();
if(p %2 == 0)
{
for( i=1;i<l; i = i + 2)
{
ch = [Link](i);
[Link](ch + “ , “ );
}
else
for( i=0;i<l ; i = i + 2)
{
ch = [Link](i);
[Link](ch + “ , “ );
}
}
void manip( int a , char ch )
{
double res ;
if(ch==’s’)
{
res= [Link](a) ;
[Link]( “ Square Root “ + res );
}
else
{
res= [Link](a) ;
[Link]( “ Cube Root “ + res );
}
}
public static void main()
{
Scanner sc =new Scanner([Link]);
String str1 ;
int a1 ;
char ch1 ;
[Link](“ Enter String “);
str1 = [Link]();
[Link](“Enter Any Number“);
a1 = [Link]();
[Link](“Enter Any Character “);
ch1 = [Link]().charAt(0);
Overload ob = new Overload();
[Link](str1, p1 );
[Link](a1 , ch1 );
} // main
} // class
Q22 ) 26/315
class Overload
{
void Joystring( String s , char ch1 , ch2 )
{
String st ;
st = [Link](ch1 , ch2 );
[Link]( st );
}
void Joystring( String s )
{
int p1 , p2 ;
p1 = [Link](‘ ‘) ;
p2 = [Link](‘ ‘) ;
[Link]( “ First Position Of Space “ + p1 );
[Link]( “ Last Position Of Space “ + p2 );
}
void Joystring( String s1 ,String s2)
{ s s== s1
s1 ++“ ““ + “s2;+
String st1 ,st2 ;
st1 = [Link]( “ “) ;
st2 = [Link](s2) ;
[Link](st2);
}
}
public static void main( )
{
Scanner sc =new Scanner([Link]);
String st1 ,st2;
char ch1 ;
[Link](“ Enter Two Strings “);
st1 = [Link]();
st2 = [Link]();
[Link](“Enter Two Characters “);
ch1 = [Link]().charAt(0);
ch2 = [Link]().charAt(0);
Overload ob = new Overload();
[Link](str1, p1 );
ob. Joystring (a1 , ch1 );
ob. Joystring
} // public
} // class
Q23 )
• Use a function overloading boolean process(int n) to accept the number. The
function returns true number is an Armstrong otherwise it returns false
• Use a function overloading void process(String St) to check the string is palindrome
or not.
• Use a function overloading long process( int n) to find sum of the series given by
S = 1! + 2! + 3! + ………………………………… + n!
Q24) use overloading methods
• void process( int n ) to arrange 5 digit number in ascending order.
• void process( String st ) to arrange the characters of the word in ascending order.
• int process(String st, char ch) to return number of times the search character(ch)
occurred in the string.
Q25) use overlading methods
• void manip( String st ) to accept sentence and display longest word .
• void manip( String st, String st1 ) to display all the vowels in st and all consonants in
st1.
• void manip(String st, char ch) to count the character (ch) in the given string (st).
Q26) use overloading methods
• void process( int n ) to arrange 5 digit number in ascending order.
• void process( String st ) to arrange the characters of the word in ascending order.
• int process(String st, char ch) to return number of times the search character(ch)
occurred in the string.
void process ( int n)
{
int i, m , copy;
for(i = 0 ; i<=9 ; i++ )
{
copy = n;
while(copy > 0)
{
m = n% 10;
If( m == i )
[Link]( m + “ , “ );
copy= copy /10 ;
} // while
} // for
} // process()
void process( String st )
{
int i , j , l ;
char ch;
l = [Link]();
for(i = 65 ; i< =96 ; i++)
{
for(j = 0 ; j<l ; j++ )
{
ch = [Link](j) ;
if( i == int(ch) || (i + 32) == int( ch) )
[Link]( ch + “ , “) ;
} // j loop
} // i loop
} // process()
int process(String st, char ch)
{
int i , c =0 , l ;
char ch1;
l = [Link]();
for(i = 0 ; i< l ; i++)
{
ch = [Link](j) ;
if( ch == ch1 )
c++;
} // i loop
return c ;
} // i loop
public static void main( )
{
Scanner sc =new Scanner([Link]);
int no ,c1 ;
String st1;
char ch1 ;
[Link](“ Enter Any Number “);
No = [Link]();
[Link](“ Enter Any String “);
st1 = [Link]();
[Link](“Enter Any Character “);
ch1 = [Link]().charAt(0);
Overload ob = new Overload();
[Link](no);
[Link]( st1);
c1 = [Link](st1, ch1);
[Link](“ Number of Characters Repeated = “ + c1 );
} // main
} // class