0% found this document useful (0 votes)
8 views2 pages

Q4

The document contains a Java class named 'overload' that demonstrates method overloading with three 'pattern' methods. Each method generates a different pattern based on the input parameters: two characters, one character, or an integer. The 'main' method creates an instance of the class and calls each 'pattern' method to display the corresponding patterns.

Uploaded by

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

Q4

The document contains a Java class named 'overload' that demonstrates method overloading with three 'pattern' methods. Each method generates a different pattern based on the input parameters: two characters, one character, or an integer. The 'main' method creates an instance of the class and calls each 'pattern' method to display the corresponding patterns.

Uploaded by

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

public class overload

{
void pattern(char ch1,char ch2)
{
for(int i=1;i<=4;i++)
{
for(int j=1;j<=i;j++)
{
if(i%2==0)
System.out.print(ch2);
else
System.out.print(ch1);
}
System.out.println();
}

}
void pattern(char ch)
{
for(int i=1;i<=4;i++)
{

for(int j=1;j<=4;j++)
{
System.out.print(ch);
}
System.out.println();
}
}
void pattern(int n)
{
for(int i=1;i<=4;i++)
{
for(int j=1;j<=i;j++)
{
System.out.print(n);
n++;
}
System.out.println();
}
}

public static void main(String args[])


{
overload ob = new overload();
ob.pattern('@','*');
ob.pattern('*');

ob.pattern(1);

}
}

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy