Question

Assume we have this: Point pt = new Point2D(true, 1.0, 1.0); A few of the lines...

Assume we have this:
Point pt = new Point2D(true, 1.0, 1.0);
A few of the lines below cause problems. Identify which lines, and describe the problems. (To clarify: each line causes at most one problem.) System.out.println(pt.getVisibility()); System.out.println((Point2D)pt.getRadius()); System.out.println(((Point2D)pt).getRadius()); System.out.println(((Point2D)pt).radius);
0 0
Add a comment Improve this question Transcribed image text
Answer #1

System.out.println((Point2D)pt.getRadius()); - this line give error

because getRadius function will return radius means it will return a integer or double or float kind of variable , but we are type casting that integer or double or float to Point2D so it will give error because object double/float/int cannot be typecast to any object.

error: incompatible types: double/int/float cannot be converted to Point2D

System.out.println(pt.getVisibility()); - this getVisibility function will work fine and will return the visibility

System.out.println(((Point2D)pt).getRadius()); - this getRadius function will return the radius , here in this case we are not typecasting int/double/float to Point2D object , so it will work fine
System.out.println(((Point2D)pt).radius); - this radius function will give the radius , here in this case we are not typecasting int/double/float to Point2D object , so it will work fine

pls do give a like , thank you.

Add a comment
Know the answer?
Add Answer to:
Assume we have this: Point pt = new Point2D(true, 1.0, 1.0); A few of the lines...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • You have just begun working as an assistant director for one of the service lines for...

    You have just begun working as an assistant director for one of the service lines for an 800-bed acute care hospital (based on your own background and interests, select a service line you will work for). Within the first few weeks of your employment the director approaches you to tell you that he needs you to undertake a research project. You will come up with a problem that may impact the service line you are working for and answer the...

  • IVOVI U UL Question 46 Suppose we have Random rand = new Random(); Which of the...

    IVOVI U UL Question 46 Suppose we have Random rand = new Random(); Which of the following expression generates a random integer between 20 and 100, inclusive? rand.nextint() 96 80 rand.nextint() 96 80 + 20 rand.nextInt() % 81 rand.nextInt() % 81 + 20 A Moving to another question will save this response. Moving to another question will save this response. Question 47 Suppose I have the following Scanner object: File file = new File("data txt") Scanner input = new Scanner(file);...

  • Each of these problems (Problems 1-4) is worth four points Definition: Two lines or curves are said to be normal to each other at their point of intersection if they intersect there at right ang...

    Each of these problems (Problems 1-4) is worth four points Definition: Two lines or curves are said to be normal to each other at their point of intersection if they intersect there at right angles or, equivalently, if their tangent lines at the point of intersection are 1. A well-known theorem in geometry states that a line which is tangent to a circle is perpendicular to the radius of the circle at the point of tangency. Use implicit differentiation to...

  • This is the code we have to edit, i know how to do everything except finding...

    This is the code we have to edit, i know how to do everything except finding if the x and y are in the space, please explain to me when you do the code. We are using addshape() api and more. public class Skeleton { public static void main(String[] args) { //================================ //== Setting up game window ====== SpaceGame myGame; //declaring the object form the class Scanner scan = new Scanner(System.in); System.out.println("What is the window name? "); //window title text...

  • Power Train, Ltd. We have smashing systems for reporting, tracking, and controlling costs on design projects....

    Power Train, Ltd. We have smashing systems for reporting, tracking, and controlling costs on design projects. Our planning of projects is better than any I have seen at other companies. Our scheduling seemed to serve us well when we were small and we had only a few projects. Now that we have many more projects and schedule using multiproject software, there are too many occasions when the right people are not assigned to the projects deemed important to our success....

  • Analysis Problem 1 “LP” You may either solve manually or using computer tools such as MS Excel, Lindo or Lingo New pressures have arisen in our industry and we now have new constraints. We are stil...

    Analysis Problem 1 “LP” You may either solve manually or using computer tools such as MS Excel, Lindo or Lingo New pressures have arisen in our industry and we now have new constraints. We are still in the business of fabricating animal drawn vehicles for our frontier village and near-by farms.   The amount of each resource needed is given in the table below. Resource Wagon Buggy Dog-cart Lumber 20 board feet 15 board feet 5 board feet Carpentry hours 10...

  • please help An object is put at the front focal point of a convex lens. Behind...

    please help An object is put at the front focal point of a convex lens. Behind the convex lens, a plane mirror is placed perpendicularly to the principal axis of the convex lens as shown in the following picture. Find the position of the image of the object using ray diagrams. (Assume the lens and the mirror are both very large in the transverse direction.) Please also describe the details of the image (real/virtual, inverted/upright, and the magnification). Does the...

  • E) Only (a) and (b) above 15. In project scheduling, when three time estimates are given...

    E) Only (a) and (b) above 15. In project scheduling, when three time estimates are given for each activity i just one time estimate, the project scheduling method used is called: A) CPM B) PERT D) Kanban E) None of the above 16. With regard to time horizons in capacity planning, aggregate planning differs scheduling in that aggregate planning: A) is for the long-range and scheduling is for the short-range. B) is for the short-range and scheduling is for medium-range....

  • Must be done in Java. Provide the rest of the code with full comments and explanation and with proper indentation. Use...

    Must be done in Java. Provide the rest of the code with full comments and explanation and with proper indentation. Use simple methods for better understanding. Must compile. CODE PROVIDED: import java.util.ArrayList; import java.util.Scanner; public class Problem3 {    public static void main( String [] args ) {        Scanner in = new Scanner( System.in );        //PLEASE START YOUR WORK HERE        //**********************************************************                                                  //**********************************************************        // PLEASE END YOUR WORK HERE        System.out.print("END OF OUTPUT");    } } 20 points! PROBLEM 3: EXTENDED FAMILY Complete this...

  • import java.util.ArrayList; import java.util.Scanner; public class AssertDemo {    /* Work on this in a piecewise...

    import java.util.ArrayList; import java.util.Scanner; public class AssertDemo {    /* Work on this in a piecewise fashion by uncommenting and focusing on one section at a time    * in isolation rather than running everything at once.    */    public static void main(String[] args) {        assert(true);        assert(false);               warmUpAsserts();               assertWithPrimitives();               assertWithObjects();               homeworkRelatedAsserts();    }    /*    * Just a...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT