Define a class to overload the method display() as follows: void display(): To print the following format using nested loop. 1 2 1 2 1 1 2 1 2 1 1 2 1 2 1
Advertisements
प्रश्न
Define a class to overload the method display() as follows:
void display(): To print the following format using nested loop.
1 2 1 2 1
1 2 1 2 1
1 2 1 2 1
void display (int n, int m): To print the quotient of the division of m and n if m is greater than n otherwise print the sum of twice n and thrice m. double display (double a, double b, double c) - to print the value of z where
z = p × q
`p=(a+b)/c` q = a + b + c
थोडक्यात उत्तर
Advertisements
उत्तर
class overload
{
void display()
{
int r,c;
for(r=1;r<=3;r++)
{
for(c=1;c<=5;c++)
{
if(c%2==0)
System.out.print(2);
else
System.out.print(1);
}
System.out.println();
}
}
void display(int m, int n)
{
if(m>n)
System.out.println(m/n);
else
System.out.println(2*n+3*m);
}
void display(double a,double b, double c)
{
double z,p,q;
p=(a+b)/c;
q=a+b+c;
z=p*q;
System.out.println(z);
}
}shaalaa.com
या प्रश्नात किंवा उत्तरात काही त्रुटी आहे का?
