Answered step by step
Verified Expert Solution
Link Copied!

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?

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

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; } d

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Concepts of Database Management

Authors: Philip J. Pratt, Joseph J. Adamski

7th edition

978-1111825911, 1111825912, 978-1133684374, 1133684378, 978-111182591

More Books

Students also viewed these Databases questions

Question

Define social perception and explain the factors that affect it.

Answered: 1 week ago

Question

1. Television more Over watching faceing of many problems ?

Answered: 1 week ago

Question

Is there a link between chronic stress and memory function?

Answered: 1 week ago

Question

City Securities has just announced (who, whom) it will hire as CEO.

Answered: 1 week ago