Write a method called average that accepts two integer parameters and returns their average as a floating point value. Ans


EX 7.8 Overload the drawCircle method of Exercise 7.6 such that if the



Download 18.11 Kb.
Page4/5
Date16.12.2020
Size18.11 Kb.
#54714
1   2   3   4   5
7 short questions
7 short questions, 4 (2)
EX 7.8 Overload the drawCircle method of Exercise 7.6 such that if the

radius is not provided, a random radius in the range 10 to 100

(inclusive) will be used.

Ans

public void drawCircle (Graphics page, int x, int y,

Color shade)

{

int radius = (int) (Math.random()*91) + 10;



page.setColor (shade);

page.drawOval (x-radius, y-radius, radius*2,

radius*2);

}
EX 7.9 Overload the drawCircle method of Exercise 7.6 such that if



both the color and the radius of the circle are not provided, the

color will default to red and the radius will default to 40.

Ans

public void drawCircle (Graphics page, int x, int y)

{

page.setColor (Color.red);



page.drawOval (x-radius, y-radius, 80, 80);

}
EX 7.10 Discuss the manner in which Java passes parameters to a




Download 18.11 Kb.

Share with your friends:
1   2   3   4   5




The database is protected by copyright ©ininet.org 2024
send message

    Main page