answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
AysviL [449]
1 year ago
10

What is printed by the following program provided all necessary standard header files are included? Explain each line of the out

put by stating which member function generates the result and why to justify your answer.#include iostream> using namespace std; class A { public: virtual void f1() cout<<("fl in A/n") voidf2 () { cout << "f2 in A/n";} }class B: public A {public: void f1() cout <<"fl in B/n"; void f2() cout <<"f2 in B/n }void g(A &x){ x.f1(); x.f2(); int main(){A;aB:bg(a);g(b);a.f1();a.f2();b.f1();b.f2();}
Computers and Technology
1 answer:
Ostrovityanka [42]1 year ago
8 0

<u>Output:</u>

f1 in A

f2 in A

f1 in B

f2 in A

f1 in A

f2 in A

f1 in B

f2 in B  

<u>Explanation:</u>

In this snippet, the code makes use of virtual functions. A virtual function is defined as a function that is defined in the base class and redefined in the derived class. If the derived function accesses the virtual function, the program will get executed with the derived class’s version of the function.

In this code, we define the virtual function f1() in class A and also redefine it in class B which is the derived class of A. While executing the program, the function g which takes the object b (class B’s object) as a parameter. It will print class B’s version of f1() rather than class A’s version. This is working off the virtual function.

You might be interested in
You need to design a data storage scheme for Hayseed Heaven library data system. There are several hundred thousand large data r
Alekssandra [29.7K]

Answer:

Make use of hash tables

Explanation:

The appropriate thing to use for this should be a hash table.

A Hash Table can be described as a data structure which stores data in an associative manner. In a hash table, data is stored in an array format, where each data value has its own unique index value. Access of data becomes very fast if we know the index of the desired data. So we can perform Hashing on ISBN Number since its unique and based on the Hash Function w ecan store the Information record.

There is no requirement for printing the file in order - HashTables dont store the data in order of insertions, so no problems with that

It becomes a data structure in which insertion and search operations are very fast irrespective of the size of the data. So Querying books details can be fast and searching will take less time.

It can also be pointed out that it wont be too expensive for Hardware implemtation as HashTables stores data based on Hash Functions and memory consumption is also optimal which reduces memory wastages.

7 0
1 year ago
Ming is building an inexpensive computer to use for her online classes, and needs to purchase Windows. What is the most cost-eff
kodGreya [7K]

The correct answer is; She can purchase OEM codes from e-commerce sites such as Amazon or eBay.

Further Explanation:

There are some sites where OEM codes cost around 110$ or higher. it will depend on which edition of Windows she plans on purchasing. The official Microsoft website sells the codes for much higher than other e-commerce sites.

There is some ways to get the older Windows for free online using a software key from a previous purchase from a friend or one you have purchased in the past. There is also a free trial that can be used for 7 days and possibly 30 days.

Learn more about Windows at brainly.com/question/1705478

#LearnwithBrainly

5 0
1 year ago
Consider a single-platter disk with the following parameters: rotation speed: 7200 rpm; number of tracks on one side ofplatter:
horsena [70]

Answer:

Given Data:

Rotation Speed = 7200 rpm

No. of tracks on one side of platter = 30000

No. of sectors per track = 600

Seek time for every 100 track traversed = 1 ms

To find:

Average Seek Time.

Average Rotational Latency.

Transfer time for a sector.

Total Average time to satisfy a request.

Explanation:

a) As given, the disk head starts at track 0. At this point the seek time is 0.

Seek time is time to traverse from 0 to 29999 tracks (it makes 30000)

Average Seek Time is the time taken by the head to move from one track to another/2

29999 / 2 = 14999.5 ms

As the seek time is one ms for every hundred tracks traversed.  So the seek time for 29,999 tracks traversed is

14999.5 / 100 = 149.995 ms

b) The rotations per minute are 7200

1 min = 60 sec

7200 / 60 = 120 rotations / sec

Rotational delay is the inverses of this. So

1 / 120 = 0.00833 sec

          = 0.00833 * 100

          = 0.833 ms

So there is  1 rotation is at every 0.833 ms

Average Rotational latency is one half the amount of time taken by disk to make one revolution or complete 1 rotation.

So average rotational latency is: 1 / 2r

8.333 / 2 = 4.165 ms

c) No. of sectors per track = 600

Time for one disk rotation = 0.833 ms

So transfer time for a sector is: one disk revolution time / number of sectors

8.333 / 600 = 0.01388 ms = 13.88 μs

d)  Total average time to satisfy a request is calculated as :

Average seek time + Average rotational latency + Transfer time for a sector

= 149.99 ms + 4.165 ms + 0.01388 ms

= 154.168 ms

4 0
1 year ago
Jeff wants to be an archeologist. He found the information below and wants to properly cite it for his own use. The information
saw5 [17]
<span>“Detail Report for 15-1199.11-Archeologist.” O*NET OnLine. n.p., 2012. Web. 5 May 2013.</span>
7 0
1 year ago
Read 2 more answers
Does the submission include the file "SuperPower.java"? Does the file include a public class called "SuperPower"? Does the class
Oduvanchick [21]

Answer:    

Here is the program fulfilling all the requirements given:

import javax.swing.JOptionPane;      

public class SuperPower{

public static void main(String[] args) {

String power;

power = JOptionPane.showInputDialog("What is your super power?");

power = power.toUpperCase();

JOptionPane.showMessageDialog(null, power);} }

Explanation:

Does the file include a public class called "SuperPower"

See the statement:

public class SuperPower

Does the class include a public method called "main"? Is the "main" method static?

See the statement:

public static void main(String[] args)

Does the main method have a String assignment statement that uses "JOptionPane.showInputDialog"

See the statement:

power = JOptionPane.showInputDialog("What is your super power?");

Does the main method have a statement that uses "JOptionPane.showMessageDialog"?

See the statement:

JOptionPane.showMessageDialog(null, power);

Does the program convert the String from "JOptionPane.showInputDialog" using the "toUpperCase" method?

See the statement:

power = power.toUpperCase();

Does the submission include a screenshot that shows an Input dialog that asks, "What is your superpower?" Does the submission include a screenshot that shows a Message dialog stating " TO THE RESCUE!", where "" is the input converted to upper case?

See the attached screenshots

If the program does not let you enter an exclamation mark after "to the rescue" then you can alter the code as follows:

import javax.swing.JOptionPane;

public class SuperPower{

public static void main(String[] args) {

String power;

power = JOptionPane.showInputDialog("What is your super power?");

power = power.toUpperCase();

JOptionPane.showMessageDialog( null, power+"!");} } // here just add an exclamation mark which will add ! after the string stored in  power

5 0
1 year ago
Other questions:
  • A search box does all of the following EXCEPT ________.
    12·2 answers
  • "Suppose there is a class Alarm. Alarm has two class variables, code which contains a String value representing the code that de
    10·1 answer
  • Suppose that each row of an n×n array A consists of 1’s and 0’s such that, in any row i of A, all the 1’s come before any 0’s in
    15·1 answer
  • 15) The codes for class Hotel has been defined in two separate files Hotel.h, and Hotel.cpp. Which of the following statements i
    12·1 answer
  • What is an input to the Program Increment Planning process that highlights how Product Management plans to accomplish the Vision
    15·1 answer
  • What answer best explains why improper netiquette is considered dangerous? Individuals who violate user policies are often charg
    14·2 answers
  • Which expansion slot is used by an NVMe compliant device?
    9·1 answer
  • The maximum number of times the decrease key operation performed in Dijkstra's algorithm will be equal to ___________
    14·1 answer
  • What do you call the two parts of lift that go down a mine
    13·2 answers
  • Write code which takes two inputs from the user, a number of sides followed by a side length, then creates a regular polygon wit
    10·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!