Given the following three class definitions found in three different files: City.java public class City {...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Given the following three class definitions found in three different files: City.java public class City { private int data; public City (int n) { data = n; } } public int getData() { return data; } } Chicago.java public class Chicago extends City { int cData; public Chicago (int n) { super (n); cData = n; } public int getData() { return cData; } public String toString() { **** return + this.getData() + + super.getData(); Boston.java MM public class Boston extends City { private int bData; public Boston () { } } public String toString() { } Boston.java public class Boston extends City { private int bData; public Boston() { super (17); bData = 13; } ww return + this.getData() + } } public int getData() { return bData; } public String toString() { } return"" + this.getData() + } What will be the output of the following Client program? public class CityClient { public static void main(String[] args) { Chicago ch= new Chicago (11); System.out.println(ch);//Ans1 Boston bo = new Boston(); System.out.println(bo);//Ans2 Ans1: super.getData(); Ans2: + super.getData(); Given the following three class definitions found in three different files: City.java public class City { private int data; public City (int n) { data = n; } } public int getData() { return data; } } Chicago.java public class Chicago extends City { int cData; public Chicago (int n) { super (n); cData = n; } public int getData() { return cData; } public String toString() { **** return + this.getData() + + super.getData(); Boston.java MM public class Boston extends City { private int bData; public Boston () { } } public String toString() { } Boston.java public class Boston extends City { private int bData; public Boston() { super (17); bData = 13; } ww return + this.getData() + } } public int getData() { return bData; } public String toString() { } return"" + this.getData() + } What will be the output of the following Client program? public class CityClient { public static void main(String[] args) { Chicago ch= new Chicago (11); System.out.println(ch);//Ans1 Boston bo = new Boston(); System.out.println(bo);//Ans2 Ans1: super.getData(); Ans2: + super.getData();
Expert Answer:
Answer rating: 100% (QA)
Cityjava public class City private int data constructor that takes an int and initialize data to n p... View the full answer
Related Book For
Posted Date:
Students also viewed these programming questions
-
5 Extra Credit Create a class called Limits. In it, write a main method that uses definite loops to verify the following statement: For a loan of $10,000 at an annual interest rate of 3%, the limit...
-
This assignment reviews object-oriented programming concepts such as classes, methods, constructors, accessor methods, and access modifiers. It makes use of an array of objects as a class data...
-
Aircraft.java public class Aircraft implements Comparable { int numEconomySeats; int numFirstClassSeats; String model; public Aircraft(int seats, String model) { this.numEconomySeats = seats;...
-
Write a static method lg() that takes an int argument n and returns the largest integer not larger than the base-2 logarithm of n. Do not use the Math library.
-
Table 8 gives the relative frequency distribution for the weekly sales of two businesses. (a) Compute the population mean and the variance for each business. (b) Which business has the better sales...
-
Huling Associates plans to transfer $300,000 of accounts receivable to Mitchell Inc. in exchange for cash. Huling has structured the arrangement so that they retain substantially all the risks and...
-
What sources does an auditor use to test for overstated accounts payable, and how are those sources used?
-
You purchase a REIT for $50. It distributes $3 consisting of $1 in income, $0.50 in long-term capital gains, $0.30 in short-term capital gains, and $1.20 in return of capital. After a year, you sell...
-
Function f is given by f(x) = 2.5x + 3x3 - 2.6x - 5.1x - 5.6 Part A doniuslso a luodite collige ovito in aldsollqga roda noisoup a lo haq dass so On the closed interval [-.05, 1.2], determine the...
-
Draw a context diagram and a diagram 0 DFD that represents the information system at a typical library.
-
Does global criminal activity operates under the substantive criminal law and procedural criminal law concepts?
-
What does it mean to say that communication is dynamic? How can two people in a conversation be both senders and receivers simultaneously?
-
Which of these data are quantitative and which are qualitative? a. The number of years a professor has been teaching. b. The number of books a professor has written. c. Whether a professor has a...
-
What types of noise are we likely to encounter in a professional environment? Are they physical, psychological, or physiological?
-
Why does it make no sense to deflate a countrys population by its price level in order to obtain the real population?
-
What is metacommunication, and how do people metacommunicate with one another?
-
Austal Ship plans to borrow 2.87 million Australian dollars (A$) for three years. It obtains a floating rate loan from a bank at the interest rate equal to the LIBOR + 2.50 (%). Austal Ship also...
-
The water in tank A is at 270 F with quality of 10% and mass 1 lbm. It is connected to a piston/cylinder holding constant pressure of 40 psia initially with 1 lbm water at 700 F. The valve is opened,...
-
Does a nonmember function have to be a friend to access a classs members?
-
Do Programming Exercise 6 but modify it to get information from a file. The first item in the file should be the number of contributors, and the rest of the file should consist of pairs of lines,...
-
What statement would you use to create an integer variable with the name cheeses?
-
In a vapour compression refrigeration system, the condition of refrigerant before entering the compressor is (a) saturated liquid (b) wet vapour (c) dry saturated liquid (d) superheated vapour
-
The highest temperature during the cycle in vapour compression refrigeration system occurs after (a) compression (b) condensation (c) expansion (d) evaporation
-
During a refrigeration cycle, heat is rejected by the refrigerant in (a) compressor (b) condenser (c) evaporator (d) expansion valve
Study smarter with the SolutionInn App