Name the indicated formed element.
Write a concrete equals method for Pirate. Two pirates are t…
Write a concrete equals method for Pirate. Two pirates are the same if they have the same name, bounty, and gold.
State which of the following hierarchies (exactly one) is in…
State which of the following hierarchies (exactly one) is invalid in Java and why. 1: Classes Flower, Lily, and Tulip, where Lily and Tulip are both children of Flower. 2: Classes Fork, Spork, and Spoon, where Spork is a child of Fork and Spoon. 3: Classes Technology, Phone, and iPhone, where iPhone is a child of Phone, which is a child of Technology. Use this template for your answer (please type fully – you cannot copy): Option because
Write a main method for SpacePirate. It should first initial…
Write a main method for SpacePirate. It should first initialize two SpacePirates with a crew size of 1 (just themselves) and the other values as you like. Then, have the first one try to pay their bounty. Next, use an appropriate method call to form a new crew made up of these two pirates and any spaceship. Finally, print the String representation of both pirates. You do not need to show the output.
Fill in the four blanks so that randomValue has a random int…
Fill in the four blanks so that randomValue has a random integer value between 9 and 99, both ends inclusive. int randomValue = __1__ (__2__.random() * __3__) + __4__; Use this template for your answer (please type fully – you cannot copy): 1: 2: 3: 4:
Can we override private methods? If so, explain a scenario i…
Can we override private methods? If so, explain a scenario in which we would do so. If not, explain why.
Please read carefully: The remaining questions from this exa…
Please read carefully: The remaining questions from this exam are all part of the same problem, divided into many smaller questions. You will be asked to write 2 classes: Pirate (an abstract class) and SpacePirate (a concrete class, and child of Pirate). Each question will indicate the part and class you will be working on. Do NOT write getters and setters unless otherwise indicated. You won’t need any that are not indicated (and you cannot use any that are not indicated). Do NOT write Javadocs. All your constructors and methods should be visible to all classes unless otherwise noted in their description. All your instance variables and class variables should have the strictest visibility modifier. When asked for constructors or methods, do not repeat the class header or any other code. Constructors and setters must use parameter names that are the same as the related instance variable(s). You should use constructor chaining in all constructors where it can be properly applied. Your chaining must reduce the necessary code in the constructors as much as possible. You don’t need null-checks for Strings or arrays. Syntax, capitalization, and spelling matter. Canvas Tip for all Qs: Click on the dropdown that says “Paragraph” and switch to “Preformatted” to get a monospaced font – this can help in coding answers The questions begin below.
Constructor chaining … (select one)
Constructor chaining … (select one)
Write the class header and the variable declarations (a clas…
Write the class header and the variable declarations (a class without constructors or methods, with correct syntax) for Pirate (an abstract class). Besides a name, a Pirate has a bounty that represents the reward for capturing the pirate and an amount of gold that reflects the Pirate’s wealth. Pirate has the following variables: name (String) bounty (int) gold (int) pirateCount (this variable, an int, is shared between all instances and keeps track of how many pirates exist. Make sure it starts at 0)
Inheritance reduces the need to ______________ existing code…
Inheritance reduces the need to ______________ existing code. (select one)