![<terminated> Demo (6) Java Application] C:\Program Files Parent object: Parents speaks Child object: children also sing well](http://img.homeworklib.com/questions/e33a5e20-f54f-11eb-9ef8-eb33dd8408de.png?x-oss-process=image/resize,w_560)
class Parent {
public void speaks() {
System.out.println("Parents speaks");
}
}
class Child extends Parent {
public void sing() {
System.out.println("children also sing well");
}
}
public class Demo {
public static void main(String[] args) {
Parent p = new Parent();
System.out.println("Parent object: ");
p.speaks();
Child c = new Child();
System.out.println("Child object: ");
c.sing();
System.out.println("Child can even speak as his parent can");
c.speaks();
}
}
please upvote. Thanks!
Create a class Parent that has a method speaks() which shall display “Parents speaks” . Create...
Create a C++ project Create an Employee class using a separate header file and implementation file. The calculatePay() method should return 0.0f. The toString() method should return the attribute values ("state of the object"). Create an Hourly class using a separate header file and implementation file. The Hourly class needs to inherit from the Employee class The calculatePay() method should return the pay based on the number of hours worked and the pay rate. Remember to calculate overtime! Create a...
In C++, please. Given an integer numbers N, create a class 'ProblemSolution' which demonstrates inheritance with the following characteristics 1. Must inherit from 'Base' class. 2. Create a 'solution' method with an integer parameter and void return type. 3. The 'solution' method should assign the given value N into 'Base' class property 'num' and call the 'display' function of 'Base' class. What is inheritance? Inheritance is a mechanism in which one object acquires all the properties and behaviors of the...
In Java
Create an interface called
Amount
that includes a method called
setPrice
().
Create an abstract class named
Book
that inherits from the interface Amount. Include a String field
for
the book’s
title
and a double field for the book’s
Price
. Within the class, include a constructor that
requires the book title and add
two getter methods
— one that returns the title and one that returns the
price. Include an abstract method named
setPrice
().
Create a...
Create another Java class named EmployeeMain within the same project, which includes the main method. a. Include another class named Employee in the same Java file. This class has the following instance variables and instance methods. Define all the instance/static variables with private access modifier and constructors, instance/static methods with public access modifier. Instance Variables empID: int employeeName: String basicSalary: double Constructor Set the value for empID. Instance Methods Get and set methods for all instance variables. displayEmployee: Display the...
python code? 1. Create a class called Person that has 4 attributes, the name, the age, the weight and the height [5 points] 2. Write 3 methods for this class with the following specifications. a. A constructor for the class which initializes the attributes [2.5 points] b. Displays information about the Person (attributes) [2.5 points] c. Takes a parameter Xage and returns true if the age of the person is older than Xage, false otherwise [5 points] 3. Create another...
C++ Program 1. Create a class named BaseballGame that has fields for two team names and a final score for each team. Include methods to set and get the values for each data field. Your application declares an array of 12 BaseballGame objects. Prompt the user for data for each object, and display all the values. Then pass each object to a method that displays the name of the winning team or “Tie” if the score is a tie. (main.cpp,...
[JAVA] implement an abstract class that has a construtor which prints "This is constructor of abstract class", an abstract method named 'a_method' and a non-abstract method which prints "This is a normal method of abstract class". A class 'SubClass' inherits the abstract class and has a method named 'a_method' which prints "This is abstract method". Now create an object of 'SubClass' and call the abstract method and the non-abstract method.
Create a Mattress class should have fields for size (king, queen, twin), manufacturer, and price, and a constructor should set default values for each. Write set methods only for size and manufacturer. The set method for size adds $200 for king or $100 for queen. Add a toString() method that returns the data from all of the fields. A child class named AdjustableMattress extends Mattress and adds a field for adjustment type (air or mechanical), with air being the default....
Create an Item class, which is the abstract super class of all Items. Item class includes an attribute, description of type String for every item. [for eg. Book] A constructor to initialize its data member of Item class. Override toString() method to return details about the Item class. Create the ExtraCharge interface with the following details. Declare a constant RATE with value 0.25 Declare a method called calculateExtraCharge(), which returns a double value. Create the...
The purpose of this lab is to practice the concept of inheritance. We will create an Hourly class that is an Employee class. In other words, the Hourly class inherits from the Employee class. In addition, we will create a Salary class that inherits from the Employee class. Finally, we will make a Child class work as a Parent class. We will create a Manager class that inherits from the Salary class. Create a C++ project, and call it Week...