A Car class which is a subclass of FuelVehicle that has: one additional private instance variable nbSeats one constructor to initialize the instance variables overrides getCost method by adding nbseats*baseFee to mileageFees accessors
Q: Write a Hamster class that is a subclass of Pet. Include: an additional attributes called…
A: A class is a group of objects which have common properties. A constructor is a method that is used…
Q: B - RobotFriend Create a RobotFriend class. RobotFriend is a new toy just on the market. Copy the…
A: EXPLANATION: - The RobotFriend class Details: - Instance Variables Declaration private String…
Q: In Java Programming, 2 class needs a no-arg constructor and a constructor that initializes all…
A: Programming instructions: Create a class Employee and ProductionWorker which extends Employee…
Q: Write a class to represent a AlternativeEnergyCar. Select the fields and methods that fit the…
A: Hello Student, hope you are doing well, I will be trying my best to explain and fulfill your query.…
Q: A class called Author (as shown in the class diagram) is designed to model a book's author. It…
A: package Java.C.c; import java.io.IOException; import java.util.Scanner; class Author {…
Q: (Object -oriented programing) 1. Here is Java code to create a chess piece: public class…
A: class ChessPiece { public String pieceName; public String position; public…
Q: Consider the following inheritance hierarchy. A class RentedVehicle that has: - One private…
A: Answer : RentedVehicles.java package Cars; // Base Classpublic class RentedVehicle { // member…
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: Write a Person class. A Person has properties of name and age. You construct a Person object by…
A: To solve this question, we can frame the entire coding as below : Person.java //declaring a class…
Q: Create an Employee Class that will have • Two instance variable: name and workingPeriod •A class…
A: Python class and static methods : def _init__ (self) : The method init is like a constructor that…
Q: Design a ‘book’ class with title, author, publisher, price and author’s royalty as instance…
A: The following program created in Java. Created book class. Created constructor of book class for an…
Q: Given the following definitions: public abstract class Manager extends Employee { . } public class…
A: Option D. Compiler error because manager is abstract so an instance cannot be created is the correct…
Q: Given the following class definition: public class Car { private String vehicleld; public Car…
A: Note: As per our guidelines we are supposed to answer only one question. Kindly repost other…
Q: A class called Customer (as shown in the class diagram above) is designed to model a customer. It…
A: Step 1 : Start Step 2 : Defining the class Customer and inside it declare the Data members. Step 3 :…
Q: Animals need energy to move. They get energy from eating food while moving consumes energy. Create a…
A: Actually, in the program given Override the eat and move methods In the eat method: If the amount…
Q: Animals need energy to move. They get energy from eating food while moving consumes energy. Create a…
A: Programming Approach Declaring a class Animal. Declaring a private variable int that is use as a…
Q: Object Oriented Programming in JAVA You are part of a team writing classes for the different…
A: You are part of a team writing classes for the different game objects in a video game. You need to…
Q: Write a Person class. A Person has properties of name and age. You construct a Person object by…
A: public class Person { String name; int age; public Person(String theName, int theAge) { this.name…
Q: The Robot class models the state and behavior of virtual robots. Each robot corresponds to an object…
A: ALGORITHM: Declare Robot constructor default and parametrized Declare turnLeft function Declare…
Q: Create an abstract class called vehicle. The class should declare the following variables: an…
A: Given vehicle class : //Vehicle abstract class definition abstract class Vehicle { // data…
Q: Define an class named Figure containing: Two instance variable named dim1, dim2 of type double. A…
A: PROGRAM CODE: Main.java (code) import java.util.Scanner ; public class Main { public static void…
Q: Create a class Student that has the attributes: • firstName lastName year ● course ● section midterm…
A: Constructors are methods with same name as that of the classes and no return types. These are used…
Q: Complete the FoodItem class by adding a constructor to initialize a food item. The constructor…
A: main.cpp #include "FoodItem.h"#include <stdio.h>#include <iostream> using namespace std;…
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: A class RentedVehicle that has: 1.One private instance variable baseFee of type double 2.One…
A: The, code has given below:
Q: A class called Author (as shown in the class diagram) is designed to model a book's author. It…
A: Objective: This program implements the functionalities of a library. First, an Author class would be…
Q: The classes Name and Date are separate classes used as properties in the Employee class. Class…
A: ANSWER:-
Q: Description what the JAVA should execute: Create a new project called Family. Add a person class…
A: Given: Now add a new instance variable to the Person class of type Person with the identifier…
Q: Complete the partial declaration of Class Car: public class Car { // declare three…
A: this keyword takes value from current object of instance variables. A setter method is always of…
Q: CHALLENGE ACTIVITY 10.10.1: Basic derived class member override. Define a member method…
A: Here is the python code with output:-
Q: 1. Complete the partial declaration of Class Car: public class Car { // declare three private…
A: Given :
Q: Create an abstract class called Movie. The class should declare the following variables: an…
A: Below is the required code in Java and sample output:
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: The xxx_Pet classA Pet has a:– Name• Include an instance variable• Getters and setters for an…
A: Programming language is missing in the question. The below program is written in Java programming…
Q: Write a class Die representing a single die. Your class should include: An instance variable for…
A: Solution:-- 1)As given in the question it is required to provide the solution for the program…
Q: A class called Author (as shown in the class diagram) is designed to model a book's author. It…
A: The requirement is to create individual classes for different entities names as Author, Book and…
Q: The Fine class must implement an iFine interface that contains the following: public interface iFine…
A: //SpeedingFineApplication.javaimport java.util.Scanner;public class SpeedingFineApplication{…
Q: a class to package that represents your new drivable type. That type should be something that is…
A: Given add a class to package that represents your new drivable type. That type should be…
Q: The non-static class level variables and non-static methods of a class are known as O a. instance…
A: As the non-static class level variables and the nonstatic methods always contain member that belongs…
Q: To model an email message with its attachments, you are given two classes Email (models some…
A: Step 1Program Approach: Note: Since you have not provided the language name to write the code so I…
Q: There are two types of accounts - S for short term contract and L for long term contract. 3.1…
A: Actually, java is a object oriented programming language. It is a platform independent.
Q: Define a class named Document that contains an instance variable of type String named text that…
A: Java is an object oriented programming language. A class in such object oriented programming is a…
Q: A superclass Person contains: 1. Three instance variables: name, address, age. Constructor with the…
A: Answer: Our instruction is answer the first three part from the first part and I have done code and…
Q: Write a class called Dog that contains instance data that represents the dog’s name and age. •…
A: Algorithm: Start Create a class Dog with name and age as its attributes Implement constructor to…
Q: A class called Book is designed (as shown in the class diagram) to model a book written by one…
A: //this class might have been already implementedpublic class Author{ //declaring instance…
Q: Given the following definitions: public abstract class Manager extends Employee {...} public class…
A: Option D. Compiler error because manager is abstract so an instance cannot be created is the correct…
Q: ed and running time through parameters and assign these to the class variables. Create an abstract…
A: Q. Design a console program that will print details of DVDs available to buy. Make use of an…
Q: Object Oriented Programming in JAVA Define and use a class for the student record. The class…
A: Define the class Student for storing the student record. Create attributes for storing the quizzes,…
Q: A class called Book is designed (as shown in the class diagram) to model a book written by one…
A: Actually, java is a object oriented programming language.
Q: Write an application class that generates 6 objects randomly from either a Car, or a Truck, or a…
A: public class RentedVehicle{ //declare instance variable private double baseFee; //constructor for…
Java code ASAP
Step by step
Solved in 7 steps with 1 images
- Consider the following inheritance hierarchy: class A{ protected: int x, y; public: int z; }; class B: private A{ private: int a, b, c; public: void set(int x, int y, int z, int a, int b, int c); }; Int main(){ Aobja; B objb; } questions:a) How many data members does B have? Write their names. b) How many of B’s data members are visible in B? Write down their names. c) Which members of B are accessible in main()? How will they be accessed? d) If the protected Access specifier in A is changed to public, then how many members of B will be accessed in main() and how? e) Define the function set() without changing its signature as given above. f) Write a default constructor for the class B that does not have an empty parameter list. g) If the data members of A become private, then how they be initialized? h) Add a static data member in class B. Can we use this pointer with static members? If yes how?Consider the following inheritance hierarchy: class A{ protected: int x, y; public: int z; }; class B: private A{ private: int a, b, c; public: void set(int x, int y, int z, int a, int b, int c); }; Int main(){ Aobja; B objb; } a) If the protected Access specifier in A is changed to public, then how many members of B will be accessed in main() and how? b) Define the function set() without changing its signature as given above. c) Write a default constructor for the class B that does not have an empty parameter list. d) If the data members of A become private, then how they be initialized? e) Add a static data member in class B. Can we use this pointer with static members? If yes how?(Java) Q 1,2 ANSWER BOTH PART 1 AND 2!!! Explain the answer step-by-step and include verbal explanation. Thank you! PART 1: 1. Given the below Car class, write a child class of Car named Tesla. The Tesla class has an additional private boolean variable named autoPilotEnabled. It also has two constructors - a default constructor and a three argument constructor. Both constructors call the appropriate constructors of the parent class. Tesla also has a getter and setter for the autoPilotEnabled variable. Finally, it has a toString method that calls the toString of Car, as well as concatenating the autoPilotEnabled variable. public class Car { private String make;private String model;public Car() {make = "Make unknown";model = "Model unknown";}public Car(String make, String model) {this.make = make;this.model = model;} public String getMake() {return make;}public String getModel() {return model;}public void setMake(String make) {this.make = make;}public void setModel(String model)…
- [JAVA]Please create a zombie class with the following directions in the problem. The screenshot is provided.make this code an object-oriented programming: from tkinter import *def callback(r,c):global playerif player == 'X' and states[r][c] == 0 and stop_game==False:b[r][c].configure(text='X', fg='blue', bg='white')states[r][c] = 'X'player = 'O'if player == 'O' and states[r][c] == 0 and stop_game==False:b[r][c].configure(text='O', fg='orange', bg='black')states[r][c] = 'O'player = 'X'check_for_winner()def check_for_winner():global stop_gamefor i in range(3):if states[i][0]==states[i][1]==states[i][2]!=0:b[i][0].configure(bg='grey')b[i][1].configure(bg='grey')b[i][2].configure(bg='grey')stop_game = Truefor i in range(3):if states[0][i]==states[1][i]==states[2][i]!=0:b[0][i].configure(bg='grey')b[1][i].configure(bg='grey')b[2][i].configure(bg='grey')stop_game = Trueif states[0][0]==states[1][1]==states[2][2]!=0:b[0][0].configure(bg='grey')b[1][1].configure(bg='grey')b[2][2].configure(bg='grey')stop_game = Trueif…[21:46, 2020年12月8日] Antoni: The following class Pizza has incomplete codes. Write setter and getter methods for all instance variables of this class. In addition, complete the missing lines of codes for the given default constructor method and isLargePizza () method.[21:47, 2020年12月8日] Antoni: class Pizza { private string name; private double diameter; public Pizza () { //Missing lines of codes to be completed by the student } public boolean isLargePizza() { //Missing lines of codes to be completed by the student } //Missing lines of codes to be completed by the student }//end class definition Hint: When the diameter of a pizza is more than 20cm, then it is considered to be a Large Pizza. The method isLargePizza () has to return a boolean value indicating whether the Pizza object is a large pizza or not. Note: You must add required member functions or data members/variables in your program to complete its execution.
- Example Code Ch 09-6Assume that Student, Employee and Retired are all extended classes of Person, and all fourclasses have different implementations of the method getMoney. Consider the following code where... indicates the required parameters for the constructors:Person p = new Person(...);int m1 = p.getMoney(); // assignment 1p = new Student(...);int m2 = p.getMoney(); // assignment 2if (m2 < 100000)p = new Employee(...);else if (m1 > 50000)p = new Retired(...);int m3 = p.getMoney(); // assignment 323. Refer to Example Code Ch 09-6: The reference to getMoney() in assignment 1 is to the classa. Personb. Studentc. Employeed. Retirede. This cannot be determined by examining the codeDo the following program in Java Eclipse. Java Class that can be used to create a Fruit object as described below: A fruit has - a: - Date of Harvest -Color -Weight -Number of seeds a. Add all instance variables. b. The class must have getters and setters for all instance variables. c. The class must have two constructors, a no-args and a constructor that receives input for each instance variables. d. The parent class is abstract. e. its 1 abstract method and has toString() method f. its 2 children (concrete) also have toString() methods.Assume that we have four classes: Person, Teacher, Student, and PhDStudent. Teacherand Student are both subclasses of Person. PhDStudent is a subclass of Student.A.Which of the following assignments are legal, and why or why not?Person p1 = new Student();Person p2 = new PhDStudent();PhDStudent phd1 = new Student();Teacher t1 = new Person();Student s1 = new PhDStudent();Suppose that we have the following legal declarations and assignments:Person p1 = new Person();Person p2 = new Person();PhDStudent phd1 = new PhDStudent();Teacher t1 = new Teacher();Student s1 = new Student();B.Based on those just mentioned, which of the following assignments arelegal, and why or why not?s1 = p1;s1 = p2;p1 = s1;t1 = s1;s1 = phd1;phd1 = s1;
- 2) Consider the following class class Department { private: string name; const long locationNo; const longdeptId; intNumOfEmployees; static intnextDeptNo; static intnextLocationNo; public: Department( ); Department(string theName, totalEmps) void Print ( ) const; } Initialize both the values of nextDeptNo and nextLocationNo to 10000 Implement the default constructor to set the name to “Unknown”, locationNo to the current value of nextLocationNo, deptId to the current value of nextDeptNo and NumOfEmployees to zero. It should also increment the value of all static attributes by 1. Implement the other constructor to set the name and NumOfEmployees to the values that are passed to the contractor. The values of the locationNo and deptId should be assigned to the current values of nextLocationNo and nextDeptNo, respectively. This constructor should also increment the values of all static attributes by 1. The print function should print all values of all attributes (regular,…Implement the following concepts by constructing suitable classes in Java -a. Constructorsb. Constructor Overloadingc. Function Overloadingd. Function Overridinge. InheritanceCreate a class Person - Field - Name, Birthdate, Contact no and Mail idMethods - Constructor, accept and displayClass Employee - Inherits the Person classFields : Emp ID, grade, basic salary, Gross Salary, HRA (House Rent Allowance), TA (TravelingAllowance), DA (Dearness Allowance)Given:Grade Basic TAA 8000 2000B 7000 1500C 6000 1000D 5000 500Calculate Gross Salary :Gross Salary = Basic + HRA (20% of Basic) + DA (50% Basic) + TAe.g if Basic = 8000TA = 2000HRA = 20% of 8000 = 1600DA = 50 % of 8000 = 4000Gross = 8000 + 2000 + 1600 + 4000 = 15600Optional : you can implement increment function in which you can change grade of an employee andrecalculate salary with new gradehighlight the correct answer and provide proper explanation 6. A class should take any number as an argument but no other data types. Which code does this? a. public class xyz <T> b. public class xyz <T extends Number> c. public class xyz <T implements Number> d. public class xyz <T extends Integer> 7. Log4j.properties is set to 'warn'. Which would show in the log file? a. Info b. Debug c. Trace d. Error 8. Which would lock an object so that it could only be used by a single thread? a. join() b. yield() c. synchronized() d. start() 9. Which of the following is an example of a dependency between 2 objects? a. Vehicle and car b. Person and employee c. Pilot and plane d. Generic database reader and Oracle database reader