Consider the following class definition. public class ClassP private String str; public ClassP (String newstr) { String str = newStr; The ClassP constructor is intended to initialize the str instance variable to the value of the formal parameter newStr. Which of the following statements best describes why the ClassP constructor does not work as intended? a. The constructor should have a return type of String. b. The constructor should have a return type of void. c. The instance variable str should be designated public. d. The variable str should be designated public in the constructor. e. The variable str should not be declared as a String in the constructor.
Q: Define a class named Complex that will represent complex numbers. A complex number is a number of…
A: #include<bits/stdc++.h>using namespace std; class Complex { public: int real,…
Q: Using classes and arrays, the team will develop a set of functions for an online shopping system.…
A: Actually, program is an executable software that runs on a computer.
Q: Define the class Student which has private members name, department, and mark. It has public members…
A: I have implemented the given requirements in C++ as per the specifications. The code is as follows:…
Q: Consider a base class named Employee and its derived classes HourlyEmployee and PermanentEmployee…
A: #include<iostream>using namespace std; class Employee{ protected: int ID;…
Q: C++ is a programming language that can be used to Make a program that calculates the volume of…
A: C++ Program: #include <iostream>using namespace std; // Make a constant for piconst float pi =…
Q: Write a class named Employee that has the following member variables: name. A string that holds the…
A: #include <iostream>#include "Employee.h" using namespace std; int main(){ //create 3…
Q: Define an abstrat super class called Employee that contains a name (String), a social security…
A: class person { private String name; person(String s) {…
Q: Consider the following class definition that represents an AM radio class Radio { public bool…
A: Given: Consider the following class definition that represents an AM radio class Radio { public…
Q: Define a class for complex numbers. A complex number is a number of the form a + b*i where for our…
A: #include<bits/stdc++.h>using namespace std; class Complex{ // attributes public: double…
Q: 1. Write the definition of a class that has the following properties: a. The name of the class is…
A: We need to create a Employee class which have 5 data members as emp name, department number, salary,…
Q: A class called Author is designed to model a book's author. It contains: • Three private instance…
A: class Author { private String name; private String email; private boolean gender; //male=false;…
Q: (using classes SuperOverride & SubOverride) public class TestMethod { public static void…
A: Based on the screens provide, it is observed that the code provided in separate java class files .…
Q: Q1/A) Which of the following is statement True or False? And then correct the false statement? 1.…
A: Class: A class is a user defined blueprint or prototype from which objects are created. It…
Q: Consider the following code snippet: public abstract class Employee { public abstract void…
A: IV) is the correct option. A concrete class is a subclass that provides an implementation…
Q: Suppose you want to have a Shipper class that implements the Comparable interface so that you can…
A: C. public class Shipper implements Comparable<Shipper>
Q: Write a class HouseBuilder with private class members as houseArea(double, e.g. 20 square feet),…
A: abstract class HouseBuilder{ protected double houseArea; protected String houseLocation;…
Q: Create your main class called Teaching. The reference variable for the default constructor is T1 and…
A: 1. Create class Teacher 2. declare the given data member 3. Create a default constructor and assign…
Q: Using classes and arrays, the team will develop a set of functions for an online shopping system.…
A: Actually, program is an executable software that runs on a computer.
Q: Write a program to model a student class with roll number and name as the sensitive information.…
A: PROGRAM CODE: import java.util.*; // import required librariesclass student{…
Q: Given the following classes, answer the below questions. 1. Person (abstract class) that has the…
A:
Q: How many default constructors can a class have? a. A class cannot have a default constructor.…
A: Correct Option - b: only one
Q: Which of the following declarations will cause a compile-time error? A. Manager employD = new…
A: Here in a) It will cause a Compile Time Error as every employee IS NOT A Manager in other words…
Q: Consider the following class declaration: class Thing {private: int x; int y;static int z;…
A: Thing one = new Thing(); Thing two = new Thing(); Thing three - new Thing();
Q: In this Assignment you will use an abstract class to define, read, store, and print questions for a…
A: The objective is to write the code of program and create a class to define, read, store, and print…
Q: Question 2. Given the properties and default no-arg constructor for a Phone class, write a…
A: A no-argument or default constructor is used to initialize all objects properties or some of them by…
Q: Write a class HouseBuilder with private class members as houseArea(double, e.g. 20 square feet),…
A: using static System.Console; namespace ConsoleApp1 public class HouseBuilder { private double…
Q: Create a program that has the following classes: Point - Just like in the lecture, with attributes…
A: class Point { private int x; private int y; public Point() { x = y = 0; }…
Q: If class A inherits class B and class C as "class A: private class B, public class C {// class…
A: Inheritance is defined as the method of basing a class with another class as part of deriving new…
Q: True or false? When invoking a constructor from a derived class, its base class’s no-arg constructor…
A: Given: True or false? When invoking a constructor from a derived class, its base class’s no-arg…
Q: Assume that class Item has following two private data fields: private String name; private…
A: Given: Assume that class Item has following two private data fields: private String name;…
Q: Consider the following declarations: class xClass { public: void func(); void print() const ; xClass…
A: a. The constructor name is the same as the class name. In the given code, we have 2 constructors,…
Q: Define the class Student which has the private members name, department, and mark. It has the public…
A: The, code has given below:
Q: Create a class CommissionEmployee which has five protected instance variables - FirstName type…
A: Actually, Java is a high level programming language. And also object oriented . It. Is a platform…
Q: using c++ : Write a class father (name) with default constructor that prints the statement” default…
A: I have implemented the given requirements as mentioned. Comments are written for better…
Q: I want the class, BasePlusCommissionEmployee, to contain a reference to a CommisionEmployee object.…
A: Actually, Java is an Object Oriented Programming language which is platform independent and robust…
Q: ou need to write the complete code as mentioned below: i) The main class with necessary codes.…
A: Summary:In this question, we need to create a superclass, subclass, and test class to test the…
Q: Q1.) Write a Review class that has: • These private data members: • string user: ID of the user…
A:
Q: Suppose that the class Pet has a field called name that is of the type String. Write an assignment…
A: public Pet(String petsName) { } This is the constructor of class Pet. It accepts one argument of…
Q: What mistake prevents the following class declaration from functioning properly as an abstract…
A: An Abstract class is a restricted class that cannot be used to create objects. It is a partially…
Q: Write a Program in java to define a Student class, with member variables String name; int cms…
A: public class Student{ //creating specified data members private String name; private String…
Q: C++ is a programming language that can be used to Make a program that calculates the volume of…
A: Ans: Code: #include <iostream> using namespace std;class Cylinder { float r, h; public :…
Q: Assuming the following is the beginning of the constructor definition for class BasePlus-…
A: BasePlusCommissionEmployee::BasePlusCommissionEmployee(String first, string last, string ssn, double…
Q: Using classes and arrays, the team will develop a set of functions for an online shopping system.…
A: Actually, program is an executable software that runs on a computer.
Q: Write a Program to define a Television class, with member variables o String brandName; o String…
A: In Step 2, you will get the java code. In Step 3, you can see the output.
Q: Define a class called Cylinder that has the dimensions 'radius' and 'height' as its data members.…
A: // Code #include <iostream>#include <cmath>using namespace std; class Cylinder {…
Q: A method defined within a class and whose header does NOT include the static modifier is known as…
A: A class is a collection of methods and members and there are various types of methods and let's…
Q: Assume that class Item has following two private data fields: private String name; private int code;…
A: Here in super class Item we have only one Constructor that takes two argument String n and int c.…
Trending now
This is a popular solution!
Step by step
Solved in 2 steps
- problem statement: Write a java classStringCheckto do the below given checks on accepted string or strings. Each function should be coded in separate methods of the class. Give appropriate instance variables to implement the method. The user should be able to enter the string through the main function in Main class. Use a constructor to initialize the String entered by the user. Use the Main class to test all the methods in StringCheckclass. The programs should have the below given checklist: 1)Define classStringCheck with required instance variables 2)The StringCheck class should have six methods to do the below functions: *Check if the user entered string is a simple sentence? (Starts with capital letter, Ends with period, space between words). *Check if the user entered string is a question? (Check if the string starts with ac apital letter ends with a question mark, space between words) *Check if the user entered string have numbers in it? *Check if string is a valid email *Check…Q:-Write a statement in ClassA to check out the accessibility of your variable. package package_02; public class ClassB { public int x = 1; int y = 2; private int z =3; } package package_01; import package_02.ClassB; public class ClassA { public static void main(String[] args) { ClassB cb = new ClassB(); // System.out.print(cb.x); /* 1 */ // System.out.print(cb.y); /* 2 */ // System.out.print(cb.z); /* 3 */ } }Problem Class In this exercise, you are going to create the Problem class. The Problem class is used to help simulate a math fact, for example: 2 + 5 = Your class needs to contain two contructors, one that takes String, int, int that represts the operator sign(+, -, *, or /), the minimum, and maximum values for the number range, and a second constructor that takes only a String that represents the operator sign. For the second constructor, the minimum should default to zero and the maximum to ten. Your Problem object should generate 2 random integers between the minimum and maximum values (inclusively). Each Problem object should only have one set of numbers that do not change. While you may include additional helper methods, two methods need to be available to the user. The first is the answer method that should return a double that represents the answer to the problem. The second is the toString that should return a String that represents the problem. The format should be: number…
- python language Write a function that overwrite the greater than method for a class. The class has a field variable called score. The lower the score, the better. INPUT: Nothing? NOTE: this method is inside the class OUTPUT: Nothing is output RETURNED: The boolean result of the new comparisonProblem Class In this exercise, you are going to create the Problem class. The Problem class is used to help simulate a math fact, for example: 2+5= Your class needs to contain two constructors, one that takes String, int, int that represents the operator sign(+,-, *, or /), the minimum, and maximum values for the number range, and a second constructor that takes only a String that represents the operator sign. For the second constructor, the minimum should default to zero and the maximum to ten. Your Problem object should generate 2 random integers between the minimum and maximum values (inclusively). Each Problem object should only have one set of numbers that do not change. While you may include additional helper methods, two methods need to be available to the user. The first is the answer method that should return a double that represents the answer to the problem. The second is the toString that should return a String that represents the problem. The format should be: number…13. Fill in the blank for the toString object method of the Employee class. It returns the same thing the print method prints. public String toString() { }
- 8- Create an instance of the following class and call its methods. class Exam{ int grade; public: void seta (int b) (grade=b; } int geta () {return grade; } 9- When the word const is put before the variable definition, what does that mean? 10- How to concatenate two strings in C++ language? C++T/F: Instance variables are shared by all the instances of the class. T/F: The scope of instance and static variables is the entire class. They can be declared anywhere inside a class. T/F: To declare static variables, constants, and methods, use the static modifier.Write in C++ Language (Happy Coding):Create a class named 'Programming'. While creating an object of the class, if nothing is passed to it, then the message "I love programming languages" should be printed. If some String is passed to it, then in place of "programming languages" the name of that String variable should be printed.For example, while creating the object if we pass "cpp", then "I love cpp" should be printed.
- Complete the Appointment class. The class should have the following instance variables, constructors) and instance methods: 1. A properlv encapsulated String instance variable named personName 2. A properly encapsulated String instance variable named day. 3. A properly encapsulated double instance variable named duration 4. A default(no-arg) constructor that sets the per sonName instance variable to "Your Boss", day instance variable to "Monday" and duration instance variable to 1.5. 1. An overloaded constructor that takes two String parameters and one double parameter and sets the instance variables to the values passed in. 2. A getter and setter method for each instance variable. .A method named printAppointment, the method returns a String which contains the concatenation of the instance variables as shown in the sample output8. The first few lines of the Batter class are shown below. public class Batter private String name; private boolean leftHanded; private double battingAvg; Devactly accessible éa the eguals () netha) // more code not shown, including constructor(s) and // including "getter" methods for all instance variables A// (i.e. getName, isleftHanded, getBattingAvg) For example: public boolean isLeftHanded() return leftHanded; In the space below, write the method equals(), an instance method for the Batter class which would determine if two Batter objects are logically equivalent (in other words, they have the same state because all attributes are the same). The method header has been provided: nwhte this name, equals r public boolean equals (Batter otherGuy)The following class represents a runner for an event and the best time of the run is stored. #include using namespace std; class Runner { private: int num; String name; String represent; double event; double best_time; public: Runner (int n,String na,String rep,double ev,double bt) { num = n; name = na; represent = rep; event = ev; best_time = bt; } int getno(){ return num;} string getname(){return name;} string getrepresent(){return represent;} double getevent(){return event;} double getbesttime(){return best_time;} }; Write the main () function that does the following : Declare an array of runner objects and insert their data using the constructor provided. User will input the data for each object Display the name of the best runner (shortest best time) Display the average time for the runners (based on the best time for the runners). Upload your .cpp file