Question: Given the following three class definitions found in three different files: City.java public class City { private int data; public City (int n) {
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();
Step by Step Solution
3.41 Rating (151 Votes )
There are 3 Steps involved in it
Cityjava public class City private int data constructor that takes an int and initialize data to n p... View full answer
Get step-by-step solutions from verified subject matter experts
