Consider the following class definition: public class AClass { private int u; private int v; public void print() } public void set(int x, int y) public AClass() { } public AClass(int x, int y) } What is wrong with the following class definition? class BClass AClass private int w; public void print() { System.out.println("u + v + w = "+ (u + v + w); public BClass() { super(); w = 0; } public BClass(int x, int y, int z) { super(x, y); w = z;
Q: using java wride a program Consider the following class definition: public class date { private int…
A: import java.util.Scanner;public class OurDate { private int day; private int month; private int…
Q: (Java) Make the 2 following classes: Employee.java EmployeeTest.java Copy and paste the below…
A: In Java, the most searching program is of employee details. An employee is an entity that can have…
Q: Write a class named Person with data attributes for a person’s name, address, and telephone number.…
A: Python program for the above problem is given below:-
Q: Write declarations for each of the subclasses. For each subclass, supply private instance variables.…
A: public class Card{ private String name; //default constructor public Card() {…
Q: Consider the following class definition. public class Liquid { private double boilingPoint; private…
A: Here is the explanation about the behavior of the program:
Q: CLASS AND OBJECT WRITE! 1.) Write the main class of the given class Animal below that set the…
A: Step 1:- Program Approach:- 1.Create the object of the class Animal 2.call the function…
Q: Consider the following class Date, which represents a date using three ints for month, day and year:…
A: bool Date::operator==(Date d){ if (month == d.month && day == d.day && year ==…
Q: What is wrong in the following abstract class definition? abstract class XY { abstract int…
A: According to the information given:- We have to find out what is wrong in the following abstract…
Q: Design a class Circle with the following Private double data for radius One no arg constructor One…
A: //note: since the programming language is mentioned we are providing answer in cpp #include…
Q: * A class to represent a triangle defined by the x- and y-coorindates of its * three corner points…
A: The answer is follows.
Q: Predict the output of the following code: abstract class Top { private String name; Top(String…
A: Solution Here the given code i have just changed the class name test to Main Main .java abstract…
Q: If class A is a subclass of class B, then A has access to all of B's instance variables, including…
A: Private data: A private data can be accesses within the class only. Private data not allowed to…
Q: OR JAVA Implement the following classes / abstract classes below. Monster abstract class which has…
A: Monster abstract class: import java.lang.Math; abstract class Monster{ //Data members public…
Q: class Price { private: int dollars; int cents; public: Price() { dollars = cents = 0; }…
A: Solution: Given, 1. Write an implementation for both overloaded operators. != should return…
Q: Consider the following class defenition: 1. public class ClassA { 2. 3. private int[]] nums; public…
A: For the given java code, need to explain what will be the output :
Q: Q1 Define a rectangle class with the length (private double) and width (private double) as an…
A: Please refer to the following step for the complete solution to the problem above.
Q: Now write a Demo class which contains main method in order to demonstrate the behavior of all…
A: public class Main{ public static void main(String[] args) { //create Circle instace and…
Q: 2. Consider the following class definitions: public class BClass private int x; public void set(int…
A: Lets see the solution in the next steps
Q: Consider the following class defintion for class named MyClass and answer the following questions.…
A: The syntax for creating object of the class is as follows: 1. For default constructor Classname…
Q: public class AClass extends BClass { Given the valid class declaration above, suppose both AClass…
A: a) AClass abc = new Bclass(); It can be done c) AClass abc = new AClass(); It can be done as class…
Q: Consider the following Country class: public class Country{ String Integer population; } name;…
A: Java code snippet for City.java : //(ii) implementing Comparable interface class City implements…
Q: 2) Consider the following class class Department { private: string name; const long locationNo;…
A: Program descriptionThe class definition has the declarations of the static variables, regular…
Q: Consider the following class definition and answer the following question. public class MyClass {…
A:
Q: Given the following definitions: public abstract class Manager extends Employee { } public class…
A: Answer: We have explain some classes in java in brief explanation
Q: Q1: Consider the following class definition: public class AClass { private int u; private int…
A: As per Bartleby guideline: “Since you have asked multiple question, we will solve the first…
Q: Modify the given codes to remove the compilation errors. 1. public interface Carnivore {…
A: Answer: Ans-1: The code will not compile and it will be given you the two compile-time errors…
Q: choose the right answer to overcome the error public abstract class LabFinalExam 3 { public static…
A:
Q: A digital clock shows hours (between 0 and 23) and minutes (between 0 and 59). Ônce a minute, it…
A: File name: “Clock.java” public class Clock { private int hours; private int minutes;…
Q: Consider the definition of the following class: class Counter{ private: int x; double y;…
A: #include<iostream> using namespace std; class Counter{ private : int x; double y; public:…
Q: Consider the following declaration of class Quad and answer the question below. class Quad int x0,…
A: A class template provides a specification for generating classes based on parameters. Class…
Q: You can access this function from main() and display the string “Oversize” for oversize books and…
A: import java.time.LocalDate; public abstract class Publication{ //declare the fields…
Q: Write a class that implements Employee class that is described in UML diagram given below. The…
A: class Employee{ //declaring variables private int id; private String firstName;…
Q: Consider the following class definition and answer the following questions: public class MyClass {…
A: We need to find the output of the given Java code. MyClass object1=new MyClass(12,15); //This sets…
Q: Implement the following UML Class diagrams. Create several Account objects and a Bank object, then…
A: Given: the Uml diagram, for Account and Bank class: Main class objects:
Q: Define a class named Employee whose objects are records for employees. Derive this class from the…
A: Note: since programming language is not mentioned we are providing solution in c++. please repost…
Q: 4. public abstract class Test2 { private int x private int y; public abstract void display(); public…
A: Abstract class containing abstract method doesn't contain method body. Abstract class can't…
Q: Given the definition of the Person and Student classes below, public class Person{ public String m…
A: According to the information given:- We have to find the appropriate choose .
Q: The BankAccount class described below is used to represent a personal savings account with a yearly…
A: ALGORITHM:- 1. Create a class CreditAccount inheriting the BankAccount class. 2. Override the…
Q: Given the following superclass: abstract class Shape { private int sides; abstract double…
A: A class is a group of objects which have common properties. A constructor is a method that is used…
Q: Consider the definition of the following class: public class CC { private int u;…
A: Constructor is a special method that has the same name as the class name. The constructor method…
Q: b) Following program contains two different kind of errors. Identify and explain those errors?…
A: Here we have abstract class A which contains two methods private abstract method m1() and final…
Q: Find the error(s) in the following class definition: public class TestClass { private int value1;…
A: answer along with screenshots are given below
Q: Consider the following classes: public abstract class Cat { private int age; private…
A: The answer is as following:-
Q: Write a class named Person with data attributes for a person’s name, address, and telephone number.…
A: class Person{ //Defining class Person String name,address,telephoneNumber; //Declaring variables…
Q: Implement all the classes using Java programming language from the given UML Class diagram.
A: public class Shape { //declaring instance variables private String color; private boolean filled;…
Q: 7. Consider the following design for a Product class that keep track of product inventory: public…
A: public class Product { public Product(String name, double qty) { prodName = name;…
Q: 7. Consider the following design for a Product class that keep track of product inventory: public…
A: public class Product { public Product(String name, double qty) { prodName = name;…
Q: Consider the following class implementation, which represents a price in dollars and cents: class…
A: Find the below code for class implementation
Q: 3. Consider the following two classes and write down the output of the following code: abstract…
A: Given data, Consider the following two classes and write down the output of the following code:…
Q: 1- public class Student { 2 3 public abstract double calcScore(); 4 5 } Which of the following is…
A: The given code is a java code snippet where a Student class is created. The student class has method…
Trending now
This is a popular solution!
Step by step
Solved in 2 steps
- Class Inheritance with abstract class Define a class Employee with the following fields: _name, _empId, _department, _position (_title), _yearlySalary, _fullTime (a boolean: true/false) , _month , _year (time of hire) Add constructor and properties Define an abstract method GetBiMonthlySalary() (if the employee is paid twice a month) Define an abstract method GetVacationTime() that returns the number of vacation time this employee would have based on time of hire Override the ToString() method to return a string that contains the information pertaining to an employee such as: name, empId, department, and where full time or not. Define a class HourlyEmployee that inherits from Employee. This class should have 2 fields of its own: _hours (hours worked in half a month) and _wage (hourly wage) Provide necessary constructor, properties and methods Override the ToString() to also return the additional fields Gets 3 days of vacation after first year if the employee works…Create an inheritance hierarchy that a bank might use to represent customers’ bank accounts. All customers at this bank can deposit (i.e., credit) money into their accounts and withdraw (i.e., debit) money from their accounts. More specific types of accounts also exist. Savings accounts, for instance, earn interest on the money they hold. Checking accounts, on the other hand, charge a fee per transaction (i.e., credit or debit). Create an inheritance hierarchy containing base-class Account and derived classes SavingsAccount and CheckingAccount that inherit from class Account. Base-class Account should include one data member of type double to represent the account balance. The class should provide a constructor that receives an initial balance and uses it to initialize the data member. The constructor should validate the initial balance to ensure that it’s greater than or equal to 0.0. If not, the balance should be set to 0.0 and the constructor should display an error message,…Create an inheritance hierarchy that a bank might use to represent customers’ bank accounts. All customers at this bank can deposit (i.e., credit) money into their accounts and withdraw (i.e., debit) money from their accounts. More specific types of accounts also exist. Savings accounts, for instance, earn interest on the money they hold. Checking accounts, on the other hand, charge a fee per transaction (i.e., credit or debit). Create an inheritance hierarchy containing base class Account and derived classes Savings-Account and CheckingAccount that inherit from class Account. Base class Account should include one data member of type double to represent the account balance. ,int accountNumber, and String BankName (Final). · The class should provide a constructor that receives an initial balance and uses it to initialize the data member. The constructor should validate the initial balance to ensure that it’s greater than or equal to 0.0. If not, the balance should be set to 0.0…
- Create an inheritance hierarchy that a bank might use to represent customers’ bank accounts. All customers at this bank can deposit (i.e., credit) money into their accounts and withdraw (i.e., debit) money from their accounts. More specific types of accounts also exist. Savings accounts, for instance, earn interest on the money they hold. Checking accounts, on the other hand, charge a fee per transaction (i.e., credit or debit). Create an inheritance hierarchy containing base class Account and derived classes Savings-Account and CheckingAccount that inherit from class Account. Base class Account should include one data member of type double to represent the account balance. ,int accountNumber,and String BankName (Final). The class should provide a constructor that receives an initial balance and uses it to initialize the data member. The constructor should validate the initial balance to ensure that it’s greater than or equal to 0.0. If not, the balance should be set to 0.0 and the…Class A is a subclass of B. The statement A myA = new A(); B myB = myA compiles successfully. This statement shows the concept of inheritance. True or FalseURGENT FOR JAVA Implement the following classes / abstract classes below. Monster abstract class which has health point (int), damage point (int), name (String), resistance rate (int) fields and following methods. – A constructor that takes the name as a parameter and sets the health and damage points to random numbers between 10 and 100. – isDead() method which returns true if hp is less than or equal to 0, and false otherwise. – fight() method which prints the applied damage after resistance (see below). WaterMonster class whose resistance rate is %20. For example, if the damage of an instance of this class is 100, the fight method should print 80. FireMonster class whose resistance rate is %10. SlicingMonster class whose resistance rate is %5.
- Q2: Consider the following statements: public class YClass { private int a; private int b; public void one() { } public void two(int x, int y); { } public YClass() { } } class XClass extends YClass { private int z; public void one() { } public XClass() { } } YClass yObject; XClass xObject; Write the definition of the default constructor of YClass so that the instance variables of YClass are initialized to 0. Write the definition of the default constructor of XClass so that the instance variables of XClass are initialized to 0. Write the definition of the method two of YClass so that the instance variable a is initialized to the value of the first parameter of two and the instance variable b is initialized to the value of the second parameter of two. please I want solution :(Java Program This assignment requires one project with two classes. Class Employee Class Employee- I will attach the code for this: //Import the required packages. import java.text.DecimalFormat; import java.text.NumberFormat; //Define the employee class. class Employee { //Define the data members. private String id, lastName, firstName; private int salary; //Create the constructor. public Employee(String id, String lastName, String firstName, int salary) { this.id = id; this.lastName = lastName; this.firstName = firstName; this.salary = salary; } //Define the getter methods. public String getId() { return id; } public String getLastName() { return lastName; } public String getFirstName() { return firstName; } public int getSalary() { return salary; } //Define the method to return the employee details. @Override public String toString() { //Use number format and decimal format //to…Java Program This assignment requires one project with two classes. Class Employee Class Employee- I will attach the code for this: //Import the required packages. import java.text.DecimalFormat; import java.text.NumberFormat; //Define the employee class. class Employee { //Define the data members. private String id, lastName, firstName; private int salary; //Create the constructor. public Employee(String id, String lastName, String firstName, int salary) { this.id = id; this.lastName = lastName; this.firstName = firstName; this.salary = salary; } //Define the getter methods. public String getId() { return id; } public String getLastName() { return lastName; } public String getFirstName() { return firstName; } public int getSalary() { return salary; } //Define the method to return the employee details. @Override public String toString() { //Use number format and decimal format //to…
- Java Program This assignment requires one project with two classes. Class Employee Class Employee- I will attach the code for this: //Import the required packages. import java.text.DecimalFormat; import java.text.NumberFormat; //Define the employee class. class Employee { //Define the data members. private String id, lastName, firstName; private int salary; //Create the constructor. public Employee(String id, String lastName, String firstName, int salary) { this.id = id; this.lastName = lastName; this.firstName = firstName; this.salary = salary; } //Define the getter methods. public String getId() { return id; } public String getLastName() { return lastName; } public String getFirstName() { return firstName; } public int getSalary() { return salary; } //Define the method to return the employee details. @Override public String toString() { //Use number format and decimal format //to…Based on the following case study: Write a JAVA code Staff in the Officeo There are various staff positions in an organization.o These staffs have their own offices based on their position.o A higher-ranking position will get a spacious office.o Some low-ranking position might share one office. Determine inheritance classes Determine polymorphism Implement all classes Provide OfficeAppWrite Java classes to solve the following problem: A company has two types of employees. These are called Exempt and NonExempt. Exempt means the employee is not eligible for overtime pay and is paid a fixed amount each pay period. NonExempt means the employee is paid by the hour and receives 1.5 times the hourly rate for hours worked over 40. Each Employee has an id number which is a string. They also have a name. Employee should be an abstract class with the member variables described in number 2. Employee should have an abstract method called findPay, a toString method, and it should implement the Comparable interface. Use alphabetical order of id number to determine less than, greater than, and equal to. The toString method should produce a string like the following: Emp: ID: 4590 Emp Name: Fred Jones Employee should have an equals method. Define two employees to be equal if they have the same name and the same id number. Provide accessor and mutators for Employee. NonExempt should…