#include using namespace std; class A { private: int x; public: A(int _x) { x = _x; } int get() { return x; } }; class B { static A a; public: static int get() { return a.get(); } }; int main(void) { B b; cout << b.get(); return 0; } Execute and provide screenshot.
Q: Look at the following class definitions:class Plant:def _ _init_ _(self, plant_type):self._…
A: GIVEN: Look at the following class definitions:class Plant:def _ _init_ _(self, plant_type):self._…
Q: Write a program using method overloading and constructor overloading to do the following tasks. a)…
A: public class Speed { //declaring variables private double U; private double A; private double K;…
Q: The parts of the code that need fixing are in the comments. Code is in Python.
A: class TicTacToePlayer: # Player for a game of Tic Tac Toe def __init__(self, symbol, name):…
Q: Write c# equivalent statements for the following: There is a book library. Define classes…
A: Arrays in C# are actually objects, and not just addressable regions of contiguous memory as in C and…
Q: Write a program using method overloading and constructor overloading to do the following tasks. a)…
A: Given:
Q: Write a java program that declares two classes. The parent class is called Simple that has two data…
A: code: public class JavaExample{ int add(int num1, int num2) { return num1+num2; }…
Q: amountofcontainers int amountofholds: int Gload (containes: int) load (type: String ) 1) Create a…
A: public class Ship { public int length; public double grosstonnage; public String flag; public…
Q: Class Citizen holds two states i.e., “cnic” of type integer and “name” of type String, and a setter…
A: We have a class Citizen that have 2 data members as "cnic" of integer type and "name" of String…
Q: Here's the Coin class definition. Complete the missing parts of the implementation. class Coin…
A:
Q: class Al void methodA(){ } void methodB(); } class B extends A{ void methodA(){ } } O class A should…
A: 1. The correct option is- everything is okay Explanation: The given code is: abstract class A{ {}…
Q: (Java) 7.1 Code: Look at the following Person.java class code: class Person{ public String name;…
A: We need to add getter and setter methods in Person.java class and need to rectify some errors.…
Q: 1.1. Write a front-end class called Debug and save it in a file called Debug.cpp. This class must…
A: Objective: A CPP file should be created naming "Debug.cpp" that has two static public members, i.e.…
Q: Base class A Base class B Private : Private: int B_value; int B_value; Protected: Protected: Public:…
A: EXPLANATION: In these given classes, class A has member variable A_value as a private variable,…
Q: 1. A point in the x-y plane is représented by its x-coordinate and y- coordinate, Design the class…
A: First we are creating point in the x-y plane Code:- public class Point { protected…
Q: It is a library service program to issue book based on ISBN and book title. Identify the code smells…
A: Consider the Borrower class.
Q: Exercise 1 • Implement a constructor for the Person class • Implement a constructor for the Student…
A: As per Bartleby we can anwer only one question answer at a time if you need another question answer…
Q: Error or Run time Error? 1 MustInherit Class Baseclass 3 Dim a As Integer 4 5 Public NotQxerridable…
A: Consider the Given code :
Q: abstract class A ( protected int getVal() { return this.getVal(); } protected abstract int…
A: As per Bartleby's rules, we are answering only the first question. Also, the second question is not…
Q: abstract class A{ int a; int b; abstract void methodA(); class B extends A{ int a; void methodA(){…
A: Objective: Two questions are given on java inheritance and abstract class or method characteristics.…
Q: Fill-in-the-Blank Normally a class’s _______________________________ are declared to be private and…
A: The answer is : member variables member functions.
Q: SOLVE IN "C#" Write c# equivalent statements for the following: There is a book library. Define…
A: using System; class book{ string name; string author_name; public book(String b, string a)…
Q: public class Account{ public double balance; public Account(double x){ balance = x; %3D } } public…
A: Answer: Create a separate module of class Account and Save the file as account.java package…
Q: class Vehicle { String s = "This is my vehicle" ; } class Car extends Vehicle { String s = "This is…
A: Given java code :- class Vehicle{ String s = "This is my vehicle" ;}class Car extends Vehicle{…
Q: Class to class conversion can be done in source as well as destination class. write a program to…
A: Answer :- Yes, class to class conversion can be done in source as well as destination class.…
Q: Question :- Add a statement to the classA to test whether myChar is accessible. public class ClassB…
A: A variable is unaccessible outside a class if it is declared as private. I.e a variable that is…
Q: Polymorphism in Java is Select one: a.when a program uses several different types of objects, each…
A: I have provided solution in step2.
Q: What is the output
A: #include <iostream> using namespace std;class baseClass{ public:void print()…
Q: reate a class called Student (Student.java). It should have the following private data members:…
A: The detailed description is provided for a java class named Student which is to be implemented as a…
Q: class xClass public: void func () ; void print () const; xClass (); xClass (int, double): private:…
A: 1) count the members does xClass have means just count the member function in the xClass- like here…
Q: Pet Whisperer Define a public class Whisperer that provides a single class method named…
A: Java Code for Above : //class in which method is defined class Whisperer{ //method…
Q: TOPIC: Inheritance In Python, modify the given code based on the given specifications below. Create…
A: Solution: Given, In Python, modify the given code based on the given specifications below.…
Q: Write a Java class Student that is fully encapsulated and has a private data member name. The class…
A: class Student { // Declare name variable to store Name into it private String name;…
Q: Cpp program Write the implementation of the methods of the Account class. Do not omit the definition…
A:
Q: Add a constructor for Animal class shown. The constructor should pass in a string parameter named…
A: Class constructor : Constructor is a special method of the class. The name of the constructor is…
Q: 2. Implement the following classes: Person Employee name: String age: int address: String…
A: Answer: Java Source Code: Main.java: public class Main{ public static void main (String[] args) {…
Q: Base class A Base class B Private : int B_value; Private : int B_value; Protected: Protected:…
A: Sample Response: //C++ programming language, tested on CodeBlock IDE#include<iostream>using…
Q: public class Animal{ public Animal() { System.out.println("ANIMAL"); } } public class Horse extends…
A: super(): So super is used to call the parent class constructor so if any class inherit to any other…
Q: Notes: 1. You can add getters/setters as needed to these classes. 2. Some required methods are not…
A: Given: Write a JAVA program to build an appropriate implementation for the UML diagram below, which…
Q: What is the output? public static void main(String[] args) { new ChildClass(); }…
A: The program is a single inheritance in which one derived class that is child class obtains the…
Q: Ex: Superclass Person and its subclasses Student and Staff Person -name:String -address:String…
A: public class Tester { public static void main(String[] args) { //creating instances Person…
Q: Topical Information Use C++. This lab will help you practice with dynamic memory (NOT mixed with…
A: Procedure Followed: Create an array for holding heat temperatures of the rod. Initially, Array…
Q: class Test4 { int i; Test4 (int m){ i = m; class Test5 extends Test4{ private int j; Il add a…
A: The program illustrates the inheritance, polymorphism (overloading), and super keyword. Test4 is a…
Q: 1 using static System.Console; 2 class ShapesDemo 3 { static void Main() { abstract class…
A: Netezza is the appliance of IBM, whereas it is not used in big data to provide high storage; it is…
Q: use the following partial class definitions: public class A1 { public int x; private int y; public…
A: Given that, Which of the following lists of instance data are accessible in class A2?a) x, y, z, a,…
Q: python question Design BDTeam class and AusTeam class which inherit from CricketTeam class so that…
A: Algorithm: Start Create a class BDTeam which inherits CricketTeam and which has attributes…
Q: The base class Pet has attributes name and age. The derived class Dog inherits attributes from the…
A: Required: The base class Pet has attributes name and age. The derived class Dog inherits…
Q: Implement “SoftwareEngineer” and “CheifEngineer” class derived from “Employee” class with necessary…
A: Here I have created both SoftwareEngineer and CheifEngineer classes. In both the classes, the same…
Q: Write a derived class of the NumberGuesser class named RandomNumberGuesser. The derived class…
A: Solution is given below :
Q: Base class A Base class B Private : Private : int B_value; int B_value; Protected: Protected:…
A: #include <iostream> using namespace std; class A { protected: int a;…
Q: IN C++, Create a class called Invoice that a hardware store might use to represent an invoice for an…
A: Question given: Create a class for get invoice of a hardware items. Class has four instance…
#include <iostream>
using namespace std;
class A
{
private:
int x;
public:
A(int _x) { x = _x; }
int get() { return x; }
};
class B
{
static A a;
public:
static int get()
{ return a.get(); }
};
int main(void)
{
B b;
cout << b.get();
return 0;
}
Execute and provide screenshot.
Step by step
Solved in 2 steps with 1 images
- in c++ Define a new class named “Student” that must inherit from the given User class. This class manages student info: id (integer), name (string) and gpa (double). It must prevent the creation of a Student object with a negative ID or a GPA that is not between the range of 0.0 and 4.0 by generating a BadValueException error. This class will provide at least the following methods: toString method to return a string representation of the Student object in the format of “ID( <id> ) NAME( <name> ) GPA( <gpa> )” Such as ID(1234) NAME(John Smith) GPA(4.00) Note: the GPA must have 2 decimal places. isGPAGreater method that compares its gpa with another student’s gpa. It returns true if its gpa is greater than the other and false otherwise.TIME CLASS (C++) - Write a time class named timeClass - Write code to demonstrate that it works - The timeclass class will be named timeClass - The class must have these 3 constructors: #1) timeClass(); #2) timeClass(int h, int m, int s); #3) timeClass (string timeIn); - The string constructor must be capable of being separated by colons or blanks time in the 24-hour format: example 23:11:07 or 9:4:9 or 11 31 27 - DO NOT use some system functions for this assignment. You must write the code. - Yes, you can convert from string to integer stoi ( string). - In addition to the constructors, you should supply a set of getters (Accessors) getH, getM getS - In addition to that, add mutators that allow the individual setting of Hours, Minutes and Seconds: setH(int), setM ( int ) setS( int ) Include this setter ( Mutator) setTime( int NumSeconds); - So if I call setTime( 7673) you would know that that is: -- hours, -- minutes and -- seconds seconds = 53 7673 % 60…class first { public: void setX(); void print() const; protected: int y; void setY(int a); private: int x; }; Suppose that class second is derived from class first using the statement: class second: private first Determine which members of class first are private, protected, and public in class second.
- Java Questions - (Has 2 Parts). Based on each code, which answer out of the choices "A,B,C,D,E" is correct. Each question has one correct answer. Thank you. Part 1 - 5. In Java, inheritance uses __ relationship. A. is-aB. part-ofC. has-aD. member-ofE. None of the options Part 2 - 6. Given the following code, the output is __. class Apple { int x = 15; }class Banana extends Apple { int x = 25; }public class Sample { public static void main(String[] args) {Apple a1 = new Banana(); System.out.println(a1.x); }} A. Compiler errorB. 25C. 15D. 0E. None of the optionsA Person has a name (just a first name for simplicity) and friends. Store the names of the friends in a string, separated by spaces. Provide a constructor that constructs a person with a given name and no friends. Provide member functions. c++ void befriend(Person p) void unfriend(Person p) string get_friend_names()USING C++ Random Number Guesser Write a derived class of the NumberGuesser class named RandomNumberGuesser. The derived class should override the behavior of the getCurrentGuess method. It may also add member data and its own constructor. It may also override the higher(), lower() and reset() methods as you see fit. I have written a NumberGuesser class to make things easier. // NumberGuesser.h #ifndef NUMBERGUESSER_H #define NUMBERGUESSER_H #include <iostream> class NumberGuesser { protected: int low; int originalLow; int high; int originalHigh; public: NumberGuesser(int l, int h) { low = originalLow = l; high = originalHigh = h; } virtual int getCurrentGuess() { return (high + low) / 2; } virtual void higher() { low = getCurrentGuess() + 1; } virtual void lower() { high = getCurrentGuess() - 1; } virtual void reset() { low = originalLow; high = originalHigh;…
- In C++ Language: Suppose I have a class named Person. Here is how I would like to use the class: //Create a person named Dave Smith Person dave("Smith", "Dave", 'R'); //Create a person named Gal Gadot Person gal("Gadot", "Gal", 'G'); //Dave and Gal gets married gal = dave + gal; dave = dave + gal; //print Gal and Dave's new married name cout << gal << endl; cout << dave << endl; This will output the following: Gal Smith-Gadot Dave Smith-Gadot Write the class declaration for PersonIn C++ The base class Pet has private data members petName, and petAge. The derived class Dog extends the Pet class and includes a private data member for dogBreed. Complete main() to: create a generic pet and print information using PrintInfo(). create a Dog pet, use PrintInfo() to print information, and add a statement to print the dog's breed using the GetBreed() function. Ex. If the input is: Dobby2Kreacher3German Schnauzer the output is: Pet Information: Name: Dobby Age: 2Pet Information: Name: Kreacher Age: 3 Breed: German SchnauzerC++ Program: Random Number Guesser. Write a derived class of the NumberGuesser class named RandomNumberGuesser. The derived class should override the behavior of the getCurrentGuess method. It may also add member data and its own constructor. It may also override the higher(), lower() and reset() methods as you see fit. To get everyone started off on the same page I have written a NumberGuesser class. It is defined entirely in-line in the following file: NumberGuesser.h (Links to an external site.) https://fog.ccsf.edu/~mluttrel/cs110b/NumberGuesser.h In the current NumberGuesser class the getCurrentGuess() method returns the midpoint of the range of possible values. In your RandomNumberGuesser class the getCurrentGuess() method should return a randomly generated number in the range of possible values. Note that repeated calls to getCurrentGuess() should always return the same value for both classes if neither the higher() or the lower() functions are called. Consider the…
- TOPIC: Inheritance In Python, modify the given code based on the given specifications below. Create another class, “Food.” For the Food class, the specifications are: The object will have the following attributes on initialization: weight (weight of the food in kg) energy_add (amount of energy it will add once consumed) happiness_add (amount of happiness it will add once consumed) Modify the Child and the Friends classes such that: Instead of accepting a string (as food) in the eat method, the method should accept a Foodobject Once a Child/Friendsobject eats a Food object: The added weight should be the Food object’s weight The added energy should be the Food object’s energy_add The added happiness should be the Food object’s happiness_add The given code (can also be found on the picture): class Child: def __init__(self, child_number: int, name: str, weight: float): self.child_number = child_number self.name = name self.weight = weight def…TOPIC: Inheritance In Python, modify the given code based on the given specifications below. Create another class, “Food.” For the Food class, the specifications are: The object will have the following attributes on initialization: weight (weight of the food in kg) energy_add (amount of energy it will add once consumed) happiness_add (amount of happiness it will add once consumed) Modify the Child and the Friends classes such that: Instead of accepting a string (as food) in the eat method, the method should accept a Foodobject Once a Child/Friendsobject eats a Food object: The added weight should be the Food object’s weight The added energy should be the Food object’s energy_add The added happiness should be the Food object’s happiness_add After modifying the Child and Friends behavior, simulate a small group of Friends. In the main code, do the following: Accept a positive integer from the user that determines the number of friends and create a number of Friends specified…True or False ___(40) When a class is defined without a constructor, Java automatically provides a default constructor.