Consider the two pieces of codes below, and answer the following questions. Program A: class Star...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Consider the two pieces of codes below, and answer the following questions. Program A: class Star { }; public class BlackHole extends Star { private String name; public BlackHole(int mm) { return; }; // X public static void main(String[] args) { BlackHole x = new BlackHole(); } } Program B: class Star { }; public class BlackHole extends Star { private String name; public int BlackHole(int mm ) { return 0; }; // Y public static void main(String[] args) { BlackHole x new BlackHole(); } } Hints: The name of the class methods could have the same name like the class. However, the will cause the confusion and is a very bad programming practice. So, never name your class methods like the way we name the ctor. Line Y is a ctor Program A has implicit (invisible) no-argument ctor Line X is a ctor Program A can compile and run Program B can compile and run Program B has implicit (invisible) no-argument ctor Naming the class methods.. Consider the two pieces of codes below, and answer the following questions. Program A: class Star { }; public class BlackHole extends Star { private String name; public BlackHole(int mm) { return; }; // X public static void main(String[] args) { BlackHole x = new BlackHole(); } } Program B: class Star { }; public class BlackHole extends Star { private String name; public int BlackHole(int mm ) { return 0; }; // Y public static void main(String[] args) { BlackHole x = new BlackHole(); } } Consider the codes below. Choose the correct statements below. class Star { } public class BlackHole extends Star { private String name; public int BlackHole(double mass) { return 0; }; // A } public static void main(String[] args) { BlackHole x = new BlackHole(); = x. BlackHole(10.0); int y } ctor must have no return statement The codes compile and run ctor must have no return type Any non-constructor methods cannot have the same name as the class. The ctor of class BlackHole is overloaded Line A is a ctor. Consider the following code snippet. Choose the statements that compile (i..e, the existence of the statements will not cause compilation failure.) class Star { double mass; } class RedGiant extends Star { RedGiant() { super(); } // A RedGiant(int mass) { super(mass); } // B RedGiant (double mass) { super(mass); return; } // C Star(double mass) { this.mass = mass; } double Star () { return 0.0;} Star () { } } public class Ctor { } 00 E U A D public static void main(String[] args) { RedGiant r = new RedGiant(); // D r.Star(); // E } Consider the two pieces of codes below, and answer the following questions. Program A: class Star { }; public class BlackHole extends Star { private String name; public BlackHole(int mm) { return; }; // X public static void main(String[] args) { BlackHole x = new BlackHole(); } } Program B: class Star { }; public class BlackHole extends Star { private String name; public int BlackHole(int mm ) { return 0; }; // Y public static void main(String[] args) { BlackHole x new BlackHole(); } } Hints: The name of the class methods could have the same name like the class. However, the will cause the confusion and is a very bad programming practice. So, never name your class methods like the way we name the ctor. Line Y is a ctor Program A has implicit (invisible) no-argument ctor Line X is a ctor Program A can compile and run Program B can compile and run Program B has implicit (invisible) no-argument ctor Naming the class methods.. Consider the two pieces of codes below, and answer the following questions. Program A: class Star { }; public class BlackHole extends Star { private String name; public BlackHole(int mm) { return; }; // X public static void main(String[] args) { BlackHole x = new BlackHole(); } } Program B: class Star { }; public class BlackHole extends Star { private String name; public int BlackHole(int mm ) { return 0; }; // Y public static void main(String[] args) { BlackHole x = new BlackHole(); } } Consider the codes below. Choose the correct statements below. class Star { } public class BlackHole extends Star { private String name; public int BlackHole(double mass) { return 0; }; // A } public static void main(String[] args) { BlackHole x = new BlackHole(); = x. BlackHole(10.0); int y } ctor must have no return statement The codes compile and run ctor must have no return type Any non-constructor methods cannot have the same name as the class. The ctor of class BlackHole is overloaded Line A is a ctor. Consider the following code snippet. Choose the statements that compile (i..e, the existence of the statements will not cause compilation failure.) class Star { double mass; } class RedGiant extends Star { RedGiant() { super(); } // A RedGiant(int mass) { super(mass); } // B RedGiant (double mass) { super(mass); return; } // C Star(double mass) { this.mass = mass; } double Star () { return 0.0;} Star () { } } public class Ctor { } 00 E U A D public static void main(String[] args) { RedGiant r = new RedGiant(); // D r.Star(); // E }
Expert Answer:
Answer rating: 100% (QA)
Detailed Explanation Answer 1 Both Program A and Program B are attempting to define a class BlackHole that extends another class Star However there are critical differences in their implementations pa... View the full answer
Related Book For
Posted Date:
Students also viewed these programming questions
-
Consider Devine Fashion from S8-6. Assume that the fixed expenses assigned to each department include only direct fixed costs of the department (rather than unavoidable fixed costs as given in S8-6):...
-
Sally owns real property for which the annual property taxes are $9,000. She sells the property to Shelley on March 1 for $550,000. Shelley pays the real property taxes for the entire year on October...
-
The financial statements of Marks and Spencer plc (M&S) are available at the books companion website or can be accessed at http://annualreport.marksandspencer.com/_assets/downloads/Marks-and...
-
Maribel Baltazar was hired by clothing retail merchandiser Forever 21 in 2007. During the hiring process, Baltazar was given an 11-page document to sign, two pages of which contained an arbitration...
-
Flexible budget, working backward. The Clarkson Company produces engine parts for car manufacturers. A new accountant intern at Clarkson has accidentally deleted the calculations on the companys...
-
Three friends, A, B, and C, start a business with investments in the ratio of 4:3:5, respectively. A invested $5,000, and all three of them agree to share profits in the ratio of their investments....
-
What are the most significant differences between the AICPA and the PCAOB standard unmodified opinion audit reports?
-
Write test class with at least two unit tests that test different cases for the closer() function described below: Either write a 3rd distinct test case for closer() or explain why 2 cases is enough...
-
Select any two business Net types (outlined in Introduction to Electronic Commerce by Kutz) and one example of each. Compare and contrast the two examples on commonalities and differences between...
-
Discuss the legal remedies that are available to an employee who is bullied or harassed in the workplace.
-
Why do you think pam changed the process for identifying concerns during the system integrations ? what effect did that have?
-
Research current information on alternative work patterns and its impact on HRM. The virtual workplace is becoming more popular. More organizations are utilizing telecommuting or flextime to respond...
-
Compare the similarities and differences of various models of workers representation exist in Japan and USA?
-
In this section, you must create FOUR quality multiple choice questions over the basic facts of the unit. Create questions over key pieces of historical fact that are the most important for the...
-
(a) Explain why the concentration of dissolved oxygen in freshwater is an important indicator of the quality of the water. (b) How is the solubility of oxygen in water affected by increasing...
-
Harry Markowitz received the 1990 Nobel Prize for his path-breaking work in portfolio optimization. One version of the Markowitz model is based on minimizing the variance of the portfolio subject to...
-
An irreversible first-order reaction takes place in a long cylindrical reactor. There is no change in volume, temperature, or viscosity. The use of the simplifying assumption that there is plug flow...
-
The reaction A B is to be carried out isothermally in a continuous-flow reactor. The entering volumetric flow rate 0 is 10 dm3/h. F A = C A . For a constant volumetric flow rate = 0 , then FA =...
-
R&B Beverages, Inc., provides a complete line of beer, wine, and soft drink products for distribution through retail outlets in central Iowa. Unit price data for 2008 and 2011 and quantities sold in...
-
A large manufacturer purchases an identical component from three independent suppliers that differ in unit price and quantity supplied. The relevant data for 2009 and 2011 are given here. a. Compute...
-
Data on quantities of three items sold in 1997 and 2011 are given here along with the sales prices of the items in 1997. Compute a weighted aggregate quantity index for 2011. Quantity Sold Item 1997...
Study smarter with the SolutionInn App