数据结构考试代考 Java代码代写 数据结构代写 数据结构代考
251Midterm 2 数据结构考试代考 Question 1 25 pts Your task for this question is to create a Node class by implementing an interface. To begin, the following interface is provided Question 1 ...
View detailsSearch the whole station
数据结构代考 About this midterm This is a four question exam; each question is worth 25 points and each question has at most two parts which vary in points.
The following is the only supporting API document for your references during the test
This is a four question exam; each question is worth 25 points and each question has at most two parts which vary in points. For each question, you will be asked to write some code and you will be asked to write an explanation as a response.
Each question will have a single text field where you will write your part A and part B responses. Since there is only one text response field, it is important to have labels for each part written.
i.e.
Part A) blah blah
Part B) blah blah
The rules during the test:
This is a two part question. Write your response for both parts in the text field below. Make sure to indicate in your response about which response is part A and part B.
Part A) Blue whales and finback whales are huge. Beluga whales are small. Below are 3 classes that model these kinds of whales. Your job is to rewrite these classes using inheritance. Basically, at the end of rewriting these classes, you should end up having 4 classes: these 3, and a superclass. Rewrite these classes so that it meets this ending requirement. Examine the three classes below and think about how you will rewrite it so that your resulting response is 4 classes as mentioned earlier. (15 points)
class BlueWhale {
private int weight;
public BlueWhale(int weight) { this.weight = weight; }
public boolean isHuge() { return true; }
}
class FinbackWhale {
private int weight;
public FinbackWhale(int weight) { this.weight = weight; }
public boolean isHuge () { return true; }
}
class BelugaWhale {
private int weight;
public BelugaWhale(int weight) { this.weight = weight; }
public boolean isHuge () { return false; }
}
Part B) What does the main method of Duck print? Please provide an explanation (do not show code). Zero points for not writing an explanation. (10 points)
class Bird { void speak() { System.out.println(“chirp”); } } class Duck extends Bird { void speak() { System.out.println(“quack”); } public static void main(String[] args) { Bird b = new Duck(); b.speak(); } }
This is a two part question. Write your response for both parts in the text field below. Make sure to indicate in your response about which response is part A and part B.
Part A) You are given a task to create a class object that keeps track of Pokemon characters. (15 points)
The Pokemon character class is defined as
class PokemonCharacter {
// You don’t need to know much about the details for this class
// It just has a bunch of methods for the character
String printName() { ... } // prints the characters name
}
Now the class you will create is called “MyPokemonCharacters”.
It will have the following methods:
In summary, you just need to create this class and that is it. So just show your code. Do not write a main method that tries to demonstrate this class. Just write the class.
With the above class that you just created, explain what you would modify in your class code when you are now asked to modify your MyPokemonCharacters class to inherit from the ArrayList.
I want an explanation for your answer. I do not want to see any code. 0 points for not writing an explanation. You must write your explanation in this format:
This is a one part question only. Write your response for this part in the text field below. Make sure to indicate in your response about which response is part A.
Part A) (25 points) You are given a file that describes countries. Its first few lines look like this:
France
Paris
China
Beijing
Italy
Rome
Every country is represented by 2 lines. The first is the name and the second is the capital city.
You are also given the following class:
public class Country {
private String name;
private String capital;
public Country(String name, String capital) {
this.name = name;
this.capital = capital;
}
}
You task is to write a Java class called CountryReader that has one method. The method should have one argument: a File representing the countries file described above. The method should return an ArrayList<Country>, which contains all the countries in the file.
This is a two part question. Write your response for both parts in the text field below. Make sure to indicate in your response about which response is part A and part B.
Part A) (10 points) One of the following classes doesn’t compile. Which one? Why not?
class Star {
private String name;
Star(String s) { name = s; }
}
class WhiteDwarf extends Star { }
Part B) (15 points) Given the following class definition, what does the main method print? Explain why. 0 points for not writing an explanation. Your explanations should be short and concise. Do write a book or one page. I want a quick answer explanation.
class Robot {
private float mass;
Robot(float m) { mass = m; }
public static void main(String[] args) {
Robot r1 = new Robot(100);
Robot r2 = new Robot(100);
if (r1.equals(r2))
System.out.println(“deeply same”);
else
System.out.println(“deeply different”);
}
View keyboard shortcuts
EditViewInsertFormatToolsTable
12pt
Paragraph
更多代写:Cs美国代写被抓 在家考托福作弊 英国final网课代修 cause and effect essay写作技巧 swot分析法特点 半群理论代考
合作平台:essay代写 论文代写 写手招聘 英国留学生代写
Midterm 2 数据结构考试代考 Question 1 25 pts Your task for this question is to create a Node class by implementing an interface. To begin, the following interface is provided Question 1 ...
View detailsCOMP S311 Online Exam Time Allowed: 3 hours java编程考试代做 Instructions - Answer ALL questions in Part I. [60%] - Answer no more than FOUR (4) questions in Part II. [40%] - The total mark...
View detailsCOMP2396 I CSIS0396 Object-oriented Programming and Java 面向对象编程代考 Only approved calculators as announced by the Examinations Secretary can be used in this examination. It is the candid...
View details