1. Engineering
  2. Computer Science
  3. i am taking a computer science course and my professor...

Question: i am taking a computer science course and my professor...

Question details

I am taking a computer science course and my professor teaches much too fast. I am feeling so overwhelmed and lost. Very worried as well, as I am trying my very hardest in this class but just cant seem to grasp it. I have just been given this assignment.... Can someone explain what I am supposed to do? Is there one class? two? are there supposed to be multiple files? :( thanks!


  • Write a Java class called a Circle that represents a circle. This circle has a field radius of type double.

  • (a) Import this class to a driver class circleDriver, and create an object of circle type. (b) What is its radius going to be? (c) Why?

  • Write a constructor that instantiates a circle with radius 3.5

  • Write a constructor that instantiates a circle with given radius

  • Test these constructors in circleDriver by initializing the constructors (3) as C1 and (4) as C2, and then printing C1.radius and C2.radius.

  • (a) What error does your program throw if you try to give your constructor a return type? (b) What does it mean? (one line)

  • (a) Write assessor (getter) for the field radius for this circles and test it in circleDriver: but before doing so, answer the following questions: (b) What should its return type be? (c) Why? (d) Why are you not passing any parameters to it?

  • (a)Change the fields of this circle in such a way that they are encapsulated, using private access modifier. (b)Why is it a good idea to encapsulate the fields? (one line) (c) what errors would printing C1.radius throw? (d) why?

  • (a)Write a class method called ‘Print’ to print the radius of Circle using your getter. (b)Test by printing C1’s radius.

  • (a) Write a setter to modify the radius value. But before you do that, answer the following questions: (b) what should its return type be? (c) Why? (d) why aren’t we passing any parameters to it?

  • Change the radius value of C1 to be 15 and print it with method Print.

  • (a) Write a class method that calculates the area of this circle. But before you do that, answer the following questions: (b) what should its return type be? (c) Why? (d) why aren’t we passing any parameters to it?

Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution