Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Can anyone help with these questions? Question 3 (1 point) Consider the following class declaration. public class Address { private int myNumber; private String myStreet;
Can anyone help with these questions?
Question 3 (1 point) Consider the following class declaration. public class Address { private int myNumber; private String myStreet; private int myZip; public Address() { /* implementation not shown */ } public Address(int zip) { /* implementation not shown */ } public Address(int number, String street) { /* implementation not shown */ } public Address(int number, String street, int zip) { /* implementation not shown */ } // No other constructors } Which of the following declarations will cause a compilation error? O Oc Address location = new Address(); Address location = new Address(90210); Address location = new Address(9147, "East Springfield Road"); Address location = new Address(90210, 9147, "East Springfield Road"); Address location = new Address(9147, "East Springfield Road", 90210); Od e Consider the class below: public class Stuff { public Stuff() { System.out.print("one"); } public Stuff(int x) { System.out.print("two"); } public Stuff(double x) { System.out.print("three"); } } What is output by the following? Stuff something = new Stuff(8); a one Ob two three d twothree o e Nothing is printed Consider the following method maximum, which is intended to return the largest of three integers. public static int maximum(int a, int b, int c) if ((a > b) && (a > c)) { return a; } else if (/* missing condition * ) { return b; else { return c; } } Which of the following should replace /* missing condition */ so that maximum works as intended? a b>c b (b > a) && (b>c) (b > c) && (c>a) (c> a) && (c>b) (a > c) && (b>c) Od Questions 9 and 11 pertain to the following class, Point: public class Point { private int x; private int y; public Point() { /* missing code */ } public Point(int a, int b) { X = a; y = b; } public int getx() { return x; } public int getY() { return y; } // .. other methods not shown } Which of the following correctly implements the equals method, which is to check to make sure that each Point has the same x and y values? public boolean equals(Point p) { return (x == Point.getX() && y == Point.getY(); } public boolean equals(Point p) { return (x == p.getX() && y == p.getY(); } b Question 10 (1 point) The default constructor is meant to set x and y to 0 and 0 by calling the second constructor. What could be used to replace /* missing code */ so that this works as intended? a b this(x, y); this(0, 0); this(a, b); a = x; b = y; d Question 11 (1 point) Which of the following correctly implements a mutator method for point? a b public int getX() { return x; } public int getX() { return a; } public void setCoordinates(int a, int b) { x = a; y = b; } public String getCoordinates(int a, int b) { return x + ""' + y; } dStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started