Create a class, CallClass, with two methods to show call by value and call by reference. One method has two parameters that are any primitive types, whereas the other has a parameter that is an object of any class. Create a CallClassTest class that calls the two methods with proper arguments to show call by value and call by reference
Q: python Write a class called Person with a constructor that takes two arguments, name and age and…
A: Python is an interpreter and loosely data type language. The attributes used in python are dynamic…
Q: Given the code snippet below, the parameterized constructor for the class "SomeClass" is not working…
A: super is used to access something related to parent class whereas this refers to current instance…
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: Q2. Write a program (Abstract+Interface) Define a class named Point containing: Two private…
A: Solution :: //==Point.java================== public class Point { private int x; private…
Q: Create an Object class and a test class to accomplish the following: Write a convertToMetric class…
A: Given, Requirements: Constructor - that accepts a length in feet (as a double) and stores it in…
Q: You have a method that expects an object from the superclass to be supplied as a parameter. If you…
A: Non-static method: The crucial word 'static' does not appear before the name of a non-static method…
Q: Create two classes, Patient and Billing, whose objects are records for a clinic. Patient will be…
A: Programming Language Java:-
Q: Modify the student class presented in this chapter as follows. Each student object should also…
A: public class Student { private String firstName, lastName; private Address homeAddress,…
Q: Write a program in BlueJ using the following hints. 1. Create a class named Book and declare the…
A:
Q: QUESTION 21 Given: public interface TestInterface { boolean errorState(); } Which methods are…
A: Option d is wrong Because we cannot extend an interface. Instead we need to implement an interface,…
Q: In a package named "lecture10", implement the following. Lecture Question • class Battery with • A…
A: Given:
Q: In a package named "lecture10“, implement the following. Lecture Question • class Battery with • A…
A:
Q: For the Circle class, create the following: • A private double instance variable m_radius. • A…
A: i.Class of circle The following class diagram depicts the design of a circle class. It includes the…
Q: Write a program in BlueJ using the_following hints. 1. Create a class named Book and declare the…
A: The Answer to the Following Problem :-
Q: A class can have how many constructor methods? Only one constructor without parameters.…
A: d.) Many constructors with different signatures
Q: Creates a class Student with 3 attributes: name, id and level. a. Add a constructor able to create a…
A: #include <iostream> using namespace std; class student{ // Declaring three attributes of…
Q: Create a class called Employee as a a derived class of the class Person. An employee record has an…
A: Below is the code in java as language is not mentioned and sample output:
Q: Create a RobotFriend class. RobotFriend is a new toy just on the market. Copy the starter class and…
A: The required class will have an instance variable "name". 'this' refers to the current object of the…
Q: Write a class named Employee which implements Comparable Interface with name and salary as data…
A: Java program to create Employee and Manager class and build the given functionality.
Q: Write a program that creates a Bus class that includes a bus ID number, number of seats, driver…
A: The problem is based on making a class named Bus and then making constructors in it. NOTE: The…
Q: Given the following code, which statement is correct? class Coffee ( } class Sugar { } class Cup {…
A: Composition class: As inheritance composition class is used for reusing the code. The composition…
Q: Create a class called Employee as a a derived class of the class Person. An employee record has an…
A: Create a class called Employee as a a derived class of the class Person. An employee record has an…
Q: Define a class Job which has three property (name, salary, description) and two behavior (getSalary,…
A: ALGORITHM:- 1. Declare the Employee class. 2. Declare the two constructor method in the class. 3.…
Q: Write a class named Employee which implements Comparable Interface with name and salary as data…
A: Note: This code should be rewritten instead of copying to the compiler otherwise it will throw a…
Q: Work on the following: Create three interfaces with the names "InterfaceOne," "IrnterfaceTwo," and…
A: In this question, we have to create three interfaces and classes. All the code is implemented below.
Q: Create a parent class Person with one attribute age and one method greet() that prints out "Hello,…
A: I give the code in Java (Because you have not mentioned any specific language )along with output and…
Q: Create a class named House With the 3 attributes named price, location and bulltyear of type double,…
A: Answer: class House { String brand; private boolean builtYear; double price; #constructor House(…
Q: • Write a class to simulate a bank account. • Data • Title name • balance • Constructors • One…
A: Bank.java --------------------------- public class Bank { //declaring data String titleName; private…
Q: Create an HourlyEmployee class that inherits from Employee and has two new instance variables:…
A: Employee.java ------------------------------------------- public class Employee { //creating…
Q: Create a subclass named Square from the superclass GeometricObject. Create an instance variable…
A: GeometricObject.java public abstract class GeometricObject {private String color = "white";private…
Q: Create an interface that shall have 2 methods and one string type attribute, also create an…
A: Given: We are given a problem where we have to design an interface that contains 2 methods declared…
Q: Given this class, please add the requested methods in the designated spaces provided. Instance…
A: public class Student { // declare instance variables here private int ID; private String…
Q: Implement an interface named Spreadable that defines the following contract: • Method named spread…
A: An interface in Java is a blueprint of a class. Following are the properties of an interface: We…
Q: Create a subclass named Square from the superclass GeometricObject. Create an instance variable…
A: Sub Class is a class which inherits the other class. It is also called a derived class or child…
Q: Build a class called BankAccount that manages checking and savings accounts. The class has three…
A: we need to provide python code for given Bank Account class
Q: Create a class named House with the 3 attributes named price, location and builtYear of type double…
A: In java, For each instance variable, a getter method returns its value while a setter method sets…
Q: In a package named "lecture10", implement the following. Lecture Question class Battery with A…
A: Given
Q: Write a program which controls a metro train and that keeps track of stations and who gets on and…
A: Actually, Python is the easiest programming language. It is a dynamically typed programming…
Q: The class "Food" has the following attributes: foodName, category, calory. Write a Python…
A: Python used to answer this question
Q: Define an interface named shape with a single method named area that calculates the area of the…
A: An interface contains variables and methods like a class but the methods in an interface are…
Q: Write a class that tests and demonstrates that your Candidate and Election classes implement the…
A: The code for the above given question is given below:
Q: a.) Write the definition of the default constructor of YClass so that the instance variables of…
A: constructors are special function/method which are used to initialize values to instance variables…
Q: Write a class called person, which contains: A private class variable, Counter, initialized with…
A: //C++ program#include <iostream> using namespace std; class person{ //class variable…
Q: Given the class declaration and instance method definitions and based on what you learned about…
A: Answer: Header filename: Rectangle.h Source filename: Rectangle.cpp
Q: Assume you have three interfaces I1, I2 & I3. The definition of these three interfaces is given…
A: The Following scenario is implemented in Java. The user can use any other language just change the…
Q: Write a convertToMetric class that has the following field: standard - holds a double, standard…
A: import java.util.*;class convertToMetric { double standard; public convertToMetric(double standard)…
Q: Design a class called Pokemon using a parameterized constructor so that after executing the…
A: Here, Code instruction is given.
Q: Create an interface called Visible that includes two methods: makeVisible and makeInvisible. Both…
A: Answer:
Q: Write a superclass called ؛Person (as shown in the class diagram), which contains: • Two instance…
A: public class Tester { public static void main(String[] args) { //creating Person instances…
Create a class, CallClass, with two methods to show call by value and call by reference.
One method has two parameters that are any primitive types, whereas the other has a
parameter that is an object of any class. Create a CallClassTest class that calls the two
methods with proper arguments to show call by value and call by reference
Trending now
This is a popular solution!
Step by step
Solved in 2 steps
- Create a class Course to describe a course according to the following requirements: A course has three attributes: courseName, courseCode, fees. Create a constructor without parameters to initialize all the instance variables to default values (0 for numbers and "" for a string). Create a constructor to initialize all the attributes to specific values. Add all setter and getter methods Create a tester class with the main method. The tester class must be named using your first and last In this class performs the following: Create a course object c1 using the default constructor. Create a course object c2 with the following information: courseName =” object oriented programing”, courseCode = “CS230” , fees = a value from your choice. Change the course fees of c2 to your age. Print the course information of c2 using getter methods I attached Typical run of the programCreate a class Book with the data members isbn, title, price. Create a class Special Edition which is subclass of Book and with a data member discountRate. Create a class BookTest with main() to test the above classes. Constructors & Methods: - Create constructors to give the values to the data members. Values shall come from user. - Create a method display() in Book class which displays isbn, title and price. Override the same display() of Book class in Special Edition. This method displays isbn, btitle, price using super.display() and display the discounted price.B - RobotFriend Create a RobotFriend class. RobotFriend is a new toy just on the market. Copy the starter class and the tester from Codecheck. A RobotFriend has a name and replies to various commands Provide a constructor that takes the name of the RobotFriend as a parameter. Remember that a constructor has the same name as the class. What does the class need to remember? That is the instance variable. Provide the following methods: public String getName () gets the name of this RobotFriend • public void setName (String newName) sets a new name for this RobotFriend • public String whatDoYouNeed () returns a string consisting of name + needs a battery charge" where name is the name of this RobotFriend (which was supplied in the constructor) public String doCommand (String whatToDo) returns a string consisting of "Your friend " + name + does not + whatToDo where name is the name of this RobotFriend and whatToDo is the parameter
- Define a class named Employee. This class should extend the Person class from the previous question. The class should have a constructor, which takes the name, age, employer (String) and salary (int) as parameters (in that order). The first two parameters should be passed to the constructor of the superclass and the value of the last two parameters should be stored in instance variables. The class should define the methods, getSalary which returns the salary of the employee and getEmployer which returns the name of the employer. Any methods from the previous question that need to be overridden should be overridden! Use super and instanceof as appropriate. I.e., for the following methods you should be able to call the method in the superclass for specific situations (e.g. the compareTo method in the superclass can be called if you receive anything other than an Employee, and this also holds for the equals method). The toString method only needs to append details and as such can also…Create a Class Pet with the following data members Identification: String species : String (e.g. cat, dog, fish etc) breed: String Age (in days): int Weight: float Dead: boolean 1. Provide a constructor with parameters for all instance variables. 2. Provide getters for all and setters for only breed, and weight 3. Provide a method growOld() that increases the age of the pet by one day. A dead pet wont grow old 4. Provide a method growHealthy(float w) that increases the weight of the pet by the given amount w. A dead pet cannot grow healthy. 5. Provide a method fallSick(float w) that reduces the weight of the pet by the given amount. The least weight a pet can have is 0 which will mean that the pet has died. If the value of weigh is 10 kg and the method is called with an argument of 11 kg then you will set it to 0 and set the dead to an appropriate value to mark the death of the pet 6. Provide a toString method that shows an appropriate well formatted string…Design an interface named Encryptor that has a single (abstract) method named encrypt with oneString argument named message. The method should return a String (which will be the encryptedmessage).Design a class named EncryptorOne that implements the Encryptor interface, and with one intinstance variable named shift. The constructor should have one parameter to initialize the shift.Implement the method encrypt so that each letter of the message sent as the argument (withlowercase letters) is shifted by the value in shift. For example, if shift is 3, a will be replaced by d, bwill be replaced by e, c will be replaced by f, and so on with a wraparound (i.e. with shift 3, x will bereplaced by a, y will be replaced by b, and z will be replaced by c). The method should return themodified version of the message. (HINT: The value of a character literal is the integer value of thecharacter in the Unicode character set. So, adding an integer (say, shift) to a character and type-casting the…
- Design an interface named Swimmer with a void method named howToSwim (). Every class of aswimmer object must implement the Swimmer interface. Design a class named Fish. Write an equalsmethod for the Fish class; have it override the Object equals method. Two Fish are equal if they havethe same values of the instance variables vertabrates (a Boolean) and edible (a String).Design a class named Goldfish that extends Fish and implements Swimmer. Implement howToSwimto display the message It is swimming. Then design a class named Comet that extends Fish andimplements Swimmer. Implement howToSwim to display the message “It is swimming”.Draw a UML diagram that involves Swimmer, Goldfish, Comet and Fish. Write a testprogram that creates an array of five Fish objects. For each object in the array, display the result ofequals method with another object of the same array and invoke its howToSwim method if it isswimmer.Java Object Oriented Programming Create a Shape class that shall have color and filled instance variables of enum Color and boolean type. The filled boolean variable shall show, whether the shape is filled (colored). The enum Color shall be defined within the class having 4 color names (choose any four). Also define getArea and getPerimeter method in Shape class, both shall return 0. Create Rectangle class with length and width attributes and a Circle class with radius attribute, of type double. Properly encapsulate all fields. Circle and Rectangle shall extend Shape class and override getArea and getPerimters methods as per its type and specific formula. In Test class, create an object of Rectangle and Circle, by initializing all attributes in constructor and print both shapes' area and perimters. In Test class, define a static method with following signature, public static void printEachShapeCount(Shape... shapes) As you know, the parent type variable can hold the…Design a class named Person with properties for holding a person’s name, address, and telephone number. Next, design a class named Customer, which is derived from the Person class. The Customer class should have a property for a customer number and a Boolean property indicating whether the customer wishes to be on a mailing list. Demonstrate an object of the Customer class in a simple application.
- Write and document the definition for the Product class. The Product class represents an item that would appear for sale on a Web site or in a department store (like a toaster). Each Product object has three instance variables: description, productNumber and price. The class has one constructor that takes three parameters in the order productNumber, description and price. The class has one accessor method named getCost(int qty) which returns the price for qty items of the Product. The class has two mutator methods—setPrice() and setDescription()—that modify the corresponding instance variables. The class has a toString() method that returns the Product as a String in the form: 34567: Small Toaster, $ 17.95. Note: use concatenation to construct the returned string. Do not use the String.format() method to format the returned value.When a class implements an interface with default methods and overrides them, the class inherits the default methods’ implementations. An interface’s designer can now evolve an interface by adding new default and static methods without breaking existing code that implements the interface. State whether the statement is true or false. If false, explain why.1. Create a Student class that implements the Person interface. As well as storing the students name and email, also store their course grade (e.g A, B, C) in a member variable. The grade should be accessible via a getGrade method. For the implementation of getDescription return a message along the lines of “A C grade student”, substituting the students actual grade.2. Create a Lecturer class that implements the Person interface. This class should also store the subject that the lecturer teaches. Add a getSubject method, and implement getDescription so that it returns a suitable message, e.g. “Teaches Biology”.3. Create a third class, Employee that implements the interface. This should also store the name of the department the Employee works in (available via getDepartment). Again, getDescription should return a suitable message.