1. Based on the diagram above, which is the correct declaration for the class FederationStarShip? 2. Based on the diagram above, the FederationStarShip class definition should contain a public method named, getWeight. Which classes can execute this method? 3. Based on the diagram above, the StarShip class should contain an instance variable declaration, protected Color bodyColor; which classes that are able to access this variable.
Q: Write a program in java for the following scenario and write a Driver class to test your…
A: Given: Write a program in java for the following scenario and write a Driver class to test your…
Q: Model the world described below by defining proper OOP items (i.e. class, abstract class, interface…
A: Interface- It can be used when you want to get a task done. All the methods of an interface should…
Q: Question 4 The answer to this question is divided into two parts. Please write your answer below…
A: (Question no 4) Programs : Note: To better understand the code please see the screenshot of the…
Q: Question 1: Create a class named ClassA. Define two instance variables along with getter and setter…
A: ALGORITHM:- 1. Create class named ClassA. 2. Define 2 private int attributes named att1 & att2.…
Q: QUESTION 18 Which of the statements regarding the super keyword is incorrect? (Choose all that…
A: ANSWER:-
Q: escribe a scenario, where using anonymous classes might not be helpful is rather proble
A: Given:- Describe a scenario, where using anonymous classes might not be helpful is rather…
Q: For the given parent class, write a child class that satisfies the following requirements: • child…
A: Inheritance: It is OOP concept where one class inherits all the methods and properties of another…
Q: Create two classes, Patient and Billing, whose objects are records for a clinic. Patient will be…
A: Programming Language Java:-
Q: When it doesn't make sense to have objects of that class To prevent developers from further…
A: Lets see the solution.
Q: A class called MyCircle, which models a circle with a center (x,y) and a radius, is designed as…
A: The required Java code is: // The MyPoint class definitionpublic class MyPoint { // Private member…
Q: Which of the following statements is used to prevent other classes extend a class named Triangle?…
A: "Final" keyword- If a class is declared with "final" keyword, then class…
Q: Write the Student class so that the given code provides the expected output. 1. Create Student class…
A: Student.printDetails()print('#########################################') mikasa = Student("Mikasa…
Q: How many parameters must be passed if only the following prototype is given to a constructor?…
A: Question. How many parameters must be passed if only the following prototype is given to a…
Q: Which one is true? A) An inner class can be declared public or private subject to the same…
A: All the statements are true. So option A,B,C,D are correct
Q: is needed to create a new instance of the class? O A field O An instance attribute OA constructor A…
A: A class is a collection of attributes and methods which act as a template to create different…
Q: What indicates that a class definition is complete? A. The first line of code that is not indented.…
A: A. The first line of code that is not intended: It is correct
Q: Create a class named ClassA. Define two instance variables along with getter and setter named: att1,…
A: Constructor is a special member function of the class. It is a method that has the same name as that…
Q: For which of these visibility modifiers, the attributes and methods of a super class be accesse from…
A: Dear Student, Void is not a visibility modifier , We can access the attributes and methods of a…
Q: Which of the following is true about abstract classes? Note that if a class can be sub-classed, this…
A: Answer:- Abstract classes cannot be instantiated, but they can be sub classed. Explanation:- Аn…
Q: Create a class named State that holds the following fields: a String for the name of the state, an…
A: // defination for TestStatepublic class TestState { public static void main(String[] args) {…
Q: using Java, create a class where the user will receive a notification if they have been inactive for…
A: MainActivity.java package com.example.comeback; import android.app.Activity; import…
Q: Find the attached file.
A: Class defitnion: Class is a user-defined data type that contains the data members and member…
Q: How many parameters must be passed if only the following prototype is given to a constructor?…
A: Some Languages supports Optional Parameters and some doesn't supports optional Parameters For…
Q: Assignment class The Assignment class should have the following three instance variables: String…
A: public static double average( List<Assignment> assignments) { double…
Q: Write and document the definition for the Product class. The Product class represents an item that…
A: Programming instructions: Create a class Product. Create required instance variables. Create a…
Q: Create a class car with make, model, year, OwnerName, RegisNo, Insurers as private fields. Create…
A: C++ supports object oriented programming . Classes are declared as class class_name.Access…
Q: 2. Consider the BlackJackCard and PlayingCard classes. a)Do these two classes have an…
A: As per our guidelines, we are supposed to answer only 1st three parts. Kindly repost the remaining…
Q: For the given parent class, write a child class that satisfies the following requirements: • child…
A: parent class- name Berry import java.io.ObjectStreamClass;import java.sql.Connection;import…
Q: Create a new project called Family. Add a person class with name, birthDate, and sex private…
A: Java used to answer this question
Q: UML diagram analysis: refer to the following UML diagram of the Loan Class. a) How many instance…
A: UNL Diagram consists of three sections: Section 1: Class Name Section 2: Data members. The attribute…
Q: 1. Create a class named Cat. Declare two (2) empty instance variables: catType (String) and…
A: In this question we have to create a java class and create some constructor methods which will set…
Q: Design, implement and test a Python class, called SphereAlly, to be used by a galactic non-profit…
A: The code is given below. Note: sample results are not provided, printed results may look different…
Q: The Player class below will contain two int attributes and a constructor. The class will also…
A: In Java, We can declare a constructor as private but we are not able to create an object of that…
Q: Please complete the following tasks: Write a class “Actor” that contains two attributes with the…
A: As language not defined doing it in Java Programming Language.
Q: For this portion of the assignment you will need to create the Employee class * based on the…
A: Actually, object is a instance of class.
Q: Create an abstract NewspaperSubscription class with fields for the subscriber name, address, and…
A: public abstract class NewspaperSubscription{ protected String name; protected String address;…
Q: Consider the following class: public final class Midterm{ int x =1; public Midterm(){} } What can be…
A: In the above example as we can see it is a class that is created in the public mode. and also…
Q: Create a new class called Post and fill in the comment details. This class represents a single…
A: Post.java: public class Post { // Attributes private String name; private String…
Q: Which of the following is the most likely scenario for a specific class? a. Its data is private and…
A:
Q: Create two classes i.e. Employee and EmployeeTest. Save the source file with the name Employee.java.…
A: A class is defined as a prototype or abstract type that encapsulates or contains the attributes and…
Q: Which of the following statements are true? Group of answer choices 1. A superclass reimplements the…
A: Below is the answer with explanation:
Q: Which statement is true? Question 14 options: An abstract method is a method that appears in a…
A: Answer to the above question about true statements of Abstract method is in step 2.
Q: Which of the following is the correct way to call the constructor of the parent class? Select one: O…
A: Introduction: Here we are required to explain the answers of above two MCQ questions about OOP's and…
Q: Assume the existence of a Window class with a constructor that accepts two integer parameters…
A: The constructor for TitledWindow class is ://TitledWindow class constructor public…
Q: Can someone please help me with the main code? The code for the business class is down below. Part…
A: import java.io.*;import java.util.*; class Business{ private String businessSymbol; private String…
Q: We already have the address and vehicle class for the system below. We will need a CarShow class…
A: As per the requirement code is developed. Note: Here Address class is not provided. So I have…
Q: hat is a static variable? Group of answer choices 1. None of the options are correct. 2. A…
A: GIVEN: What is a static variable? Group of answer choices 1. None of the options are correct.…
Trending now
This is a popular solution!
Step by step
Solved in 3 steps
- StockList Class • This class will contain the methods necessary to display various information about the stock data. • This class shall be a subclass of ArrayList. • This class shall not contain any data fields. (You don't need them for this class if done correctly). • This class shall have a default constructor with no parameters. o No other constructors are allowed. • This class shall have the following public, non-static, methods: • printAllStocks: This method shall take no parameters and return nothing. ▪ This method should print each stock in the StockList to an output file. ▪ NOTE: This method shall NOT print the data to the console. The output file shall be called all_stock_data.txt. The data should be printed in a nice and easy to read format. o displayFirstTenStocks: This method shall take no parameters and return nothing. ▪ This method should display only the first 10 stocks in the StockList in a nice and easy to read format. ▪ This method should display the data in the…Assignment:The BankAccount class models an account of a customer. A BankAccount has the followinginstance variables: A unique account id sequentially assigned when the Bank Account is created. A balance which represents the amount of money in the account A date created which is the date on which the account is created.The following methods are defined in the BankAccount class: Withdraw – subtract money from the balance Deposit – add money to the balance Inquiry on:o Balanceo Account ido Date createdjava programming language You are part of a team writing classes for the different game objects in a video game. You need to write classes for the two human objects warrior and politician. A warrior has the attributes name (of type String) and speed (of type int). Speed is a measure of how fast the warrior can run and fight. A politician has the attributes name (of type String) and diplomacy (of type int). Diplomacy is the ability to outwit an adversary without using force. From this description identify a superclass as well as two subclasses. Each of these three classes need to have a default constructor, a constructor with parameters for all the instance variables in that class (as well as any instance variables inherited from a superclass) accessor (get) and mutator (set) methods for all instance variables and a toString method. The toString method needs to return a string representation of the object. Also write a main method for each class in which that class is tested – create…
- Computer Graphics Mickey Mouse In this labwork are asked to write a GUI application using AWT. It is highly advised that you build your work and knowledge upon the last labwork. You can watch the small video demo on WebOnline to get a better understanding. In additional to what we did in Lab3 you are going to; • Add a control panel. • Add two buttons to the panel called "Smaller" and "Bigger". • Menubar of this program should have an item called "Set Default"which will reset the values of x, y, dx and dy to the values they had initially. • Modify the action listener according to the buttons and menu item. • Set the title to "Mickey" in the constructor and add your WindowListener. • Modify your paint method to draw 3 ovals which makes up Mickey Mouse silhouette. Smaller ovals have half the radius of the big oval. • The center of the circle is determined by the variables x and y, and the radius of circles should be dependent on dx and dy (which are equal since we are using circles). •…int getUpperScore(){ int upperScore = 0; for(int i = ONES; i <= SIXES; i++){ upperScore += score[i]; } return upperScore + getBonusScore(); } //Returns the score of the upper part of the board int getLowerScore(){ int lowerScore = 0; for(int i = THREE_OF_KIND; i <= YAHTZEE; i++){ lowerScore += score[i]; } return lowerScore; } //Returns the bonus points int getBonusScore(){ const int UPPER_SCORES_THRESHOLD = 63; const int BONUS_POINTS = 35; if(getUpperScore() >= UPPER_SCORES_THRESHOLD){ return BONUS_POINTS; } return 0; } //Returns the total score int getTotalScore(){ return getUpperScore() + getLowerScore(); } Test 10: Check upper board and having bonus correctly (0/3) failedThis is a subclass and doesn't has a main method yet. class Vector{Object items[];int length;int size; void Grow(){// Duplicate sizesize = size * 2; // Allocate new itemsObject new_items[] = new Object[size]; // Copy old itemsfor (int i = 0; i < length; i++)new_items[i] = items[i]; // Discard old itemsitems = new_items; // MessageSystem.out.println("Growing capacity to " + size + " elements");} public Vector(){size = 2;items = new Object[2];} public void Print(){// MessageSystem.out.println("Content:"); // Traversefor (int i = 0; i < length; i++)System.out.println(items[i]);} public void Insert(int index, Object item){// Check indexif (index < 0 || index > length){System.out.println("Invalid index");return;} // Grow if necessaryif (length == size)Grow(); // Shiftfor (int i = length - 1; i >= index; i--)items[i + 1] = items[i]; // Insertitems[index] = item; // One more itemlength++; // MessageSystem.out.println("Inserted " + item);} public void Add(Object…
- public class Plant { protected String plantName; protected String plantCost; public void setPlantName(String userPlantName) { plantName = userPlantName; } public String getPlantName() { return plantName; } public void setPlantCost(String userPlantCost) { plantCost = userPlantCost; } public String getPlantCost() { return plantCost; } public void printInfo() { System.out.println(" Plant name: " + plantName); System.out.println(" Cost: " + plantCost); }} public class Flower extends Plant { private boolean isAnnual; private String colorOfFlowers; public void setPlantType(boolean userIsAnnual) { isAnnual = userIsAnnual; } public boolean getPlantType(){ return isAnnual; } public void setColorOfFlowers(String userColorOfFlowers) { colorOfFlowers = userColorOfFlowers; } public String getColorOfFlowers(){ return colorOfFlowers; } @Override public void printInfo(){…class Node { int key; Node l, r; public Node(int item) { key = item; l = r = null; }} class Main{ Node root; Main() { root = null; } void Postorder(Node node) { if (node == null) return; Postorder(node.l); Postorder(node.r); System.out.print(node.key + " "); } void Inorder(Node node) { if (node == null) return; Inorder(node.l); System.out.print(node.key + " "); Inorder(node.r); } void Preorder(Node node) { if (node == null) return; System.out.print(node.key + " "); Preorder(node.l); Preorder(node.r); } void Postorder() { Postorder(root); } void Inorder() { Inorder(root); } void Preorder() { Preorder(root); } public static void main(String[] args) { Main tree = new Main(); tree.root = new Node(27); tree.root.l =…Rectangle Object Monitoring Create a Rectangle class that can compute the total area of all the created rectangle objects using static fields (variables). Remember that a Rectangle has two attributes: Length and Width. Implement the class by creating a computer program that will ask the user about three rectangle dimensions. The program should be able to display the total area of the three rectangle objects. For this exercise, you are required to apply all OOP concepts that you learned in class. Sample output: Enter Length R1: 1 Enter Width R1: 1 Enter Length R2: 2 Enter Width R2: 2 Enter Length R3: 3 Enter Width R3: 3 The total area of the rectangles is 14.00 Note: All characters in boldface are user inputs.
- Shape Classes Design classes Square, RightTriangle , and Triangle that encapsulate three geometric shapes. Each class should implement a method void draw (int x, int y) that “draws" a square, a right triangle, or an equilateral triangle (a triangle with three equal sides), respectively. See Figure 2. The parameters x and y specify the relative position of the figure: y lines down and x spaces acro from the current position of the screen cursor. The instance variables of each class are: int rows , the number of rows that comprise the figure, and char character , the keyboard character used for drawing the figure. Each shape of Figure 2 consists of five rows. The drawing characters are *** for the square, %' for the right triangle, and #' for the equilateral triangle. Shape (abstract) int rows char character Shape() Shape(int x, char c) int get rows() char getCharacter() void setRows(int x) void setCharacter(int x) void draw(int x, int y) (abstract) Square() Square(int x, char ch) void…class Main { publicstaticvoid main(String[] args) { // Coin myPenny = new Coin(CoinType.PENNY); // Coin myNickel = new Coin(CoinType.NICKEL); // Coin myDime = new Coin(CoinType.DIME); // Coin myQuarter = new Coin(CoinType.QUARTER); // Coin myHalfDollar = new Coin(CoinType.HALF_DOLLAR); // Coin myDollar = new Coin(CoinType.DOLLAR); // System.out.println(printValue(myPenny)); // System.out.println(printValue(myNickel)); // System.out.println(printValue(myDime)); // System.out.println(printValue(myQuarter)); // System.out.println(printValue(myHalfDollar)); // System.out.println(printValue(myDollar)); } publicstatic String printValue(Coin c){ String result = ""; // result = String.format("The value of a %s is $%.2f", c.getName(), c.getValue()); return result; } }Library Information System Design and Testing Library Item Class Design and TestingDesign a class that holds the Library Item Information, with item name, author, publisher. Write appropriate accessor and mutator methods. Also, write a tester program(Console and GUI Program) that creates three instances/objects of the Library Items class. Extending Library Item Class Library and Book Classes: Extend the Library Item class in (1) with a Book class with data attributes for a book’s title, author, publisher and an additional attributes as number of pages, and a Boolean data attribute indicating whether there is both hard copy as well as eBook version of the book. Demonstrate Book Class in a Tester Program (Console and GUI Program) with an object of Book class.