subject

Answer the following questions as briefly (but completely) as possible: 1. what is the printout of running the class c (via the command "java c") in the code below (saved in c. java)? (and, is that what you expected? ) 1: class a { 2: public a () { 3: system. out. println( "a's no-arg constructor is invoked" ); 4: } 5: } 6: 7: class b extends a { 8: } 9: 10: public class c {11: public static void main ( string [] args ) {12: b b = new b(); 13: }14: }2. what problem do you expect to see if compiling the program below? what was the error(s), if any, actually produced? 1: class a { 2: public a ( int x ) { 3: } 4: } 5: 6: class b extends a { 7: public b () { 8: } 9: }10: 11: public class c {12: public static void main ( string [] args ) {13: b b = new b(); 14: }15: }3 .which of the follow statements are true? which are false? explain why. a. a subclass is a subset of a superclass. b. when invoking a constructor from a subcass, its superclass's no-arg constructor is always invoked. c. you can override a private method defined in a superclass. d. you can override a static method defined in a superclass. 4. what is the benefit of using the @override annotation? 5. a. show the output of the following program: 1: public class test { 2: public static void main ( string [] args ) { 3: a a = new a( 3 ); 4: } 5: } 6: 7: class a extends b { 8: public a ( int t ) { 9: system. out. println( "a's constructor is invoked" ); 10: } 11: } 12: 13: class b { 14: public b () { 15: system. out. println( "b's constructor is invoked" ); 16: } 17: } b. is the no-arg constructor of object invoked when new a(3) is invoked? 6. indicate true or false for the follow statements: a. you can always successfully cast an instance of a subclass to a superclass. b. you can always successfully cast an instance of a superclass to a subclass. 7. what's wrong with the following code? 1: public class test { 2: public static void main ( string [] args ) { 3: object fruit = new fruit(); 4: object apple = (apple) fruit; 5: } 6: } 7: 8: class apple extends fruit { 9: } 10: 11: class fruit { 12: }8. when overriding the equals method, a common mistake is mistyping its signature in the subclass. for example, the equals method is incorrectly written as equals (circle circle) as shown in (a) below. it should be written as equals(object circle), as shown in (b) below. show the output of running class test using the circle class first from (a), and then from (b). explain the output.1: public class test {2: public static void main ( string [] args ) {3: object circle1 = new circle(); 4: object circle2 = new circle(); 5: system. out. println( circle1.equals( circle2 ) ); 6: }7: }a. 1: class circle { 2: double radius; 3: public boolean equals ( circle circle ) { 4: return this. radius == circle. radius; 5: } 6: }b. 1: class circle { 2: double radius; 3: public boolean equals ( object circle ) { 4: return this. radius == ((circle) circle).radius; 5: } 6: } next, try adding the "@override" annotation to the equals method in (a), and then try compiling. repeat with (b). what are the results, and are they as you expected? 9. how would you prevent a class from being extended? how would you prevent a method from being overridden? 10 . which of the following classes define legal abstract classes a.1: class a { 2: abstract void unfinished ( ) { 3: } 4: }b.1: public class abstract a { 2: abstract void unfinished ( ) { 3: } 4: }c. 1: class a { 2: abstract void unfinished ( ) ; 3: }d. 1: abstract class a { 2: protected void unfinished ( ) ; 3: }e. 1: abstract class a { 2: abstract void unfinished ( ) ; 3: }f. 1: class a { 2: abstract int unfinished ( ) ; 3: }11. suppose a is an interface. can you create an instance using "new a()"? 12. which of the following (if any) is a correct interface declaration? (assume i1 and i2 are correctly defined elsewhere.)a. 1: interface a { 2: void print () { 3: }; 4: }b. 1: abstract interface a extends i1, i2 { 2: abstract void print () { 3: }; 4: }c. 1: abstract interface a { 2: print () ; 3: }d. 1: interface a { 2: void print () ; 3: }

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 16:30
You have read about the beginnings of the internet and how it was created. what was the internet originally created to do? (select all that apply) share research. play games. communicate. share documents. sell toys
Answers: 1
question
Computers and Technology, 24.06.2019 00:00
Afashion designer wants to increase awareness about her brand. which network can she use and why she can use the blank to blank her products online. answers for the first blank: internet, extranet, or intranet answers for the second blank: market, design, and export
Answers: 1
question
Computers and Technology, 24.06.2019 09:10
  to change the number of rows and columns displayed by the excel object a. select the object and drag a size handle on the active object. b. deselect the object and drag a size handle of the object. c. deselect the object and drag a row or column divider of the object. d. select the object and drag a row or column divider on the active object.
Answers: 2
question
Computers and Technology, 24.06.2019 13:50
Write a program that performs a simple n-body simulation, called "jumping leprechauns." this simulation involves n leprechauns, numberd 1 to n. it maintains a gold value g_i for each leprechaun i, which begins with each leprechaun starting out with a million dollars worth of gold, that is, g_i = 1000000 for each i = 1,. in addition, the simulation also maintains, for each leprachaun,i, a place on the horizon, which is represented as a double-precision floating point number, x_i. in each iteration of the simulation, the simulation processes the leprachauns in order. processing a leprachaun i during its iteration begins by computing a new place on the horizon for i, which is determined by the assignment:
Answers: 3
You know the right answer?
Answer the following questions as briefly (but completely) as possible: 1. what is the printout of r...
Questions
question
Mathematics, 13.10.2020 14:01
Questions on the website: 13722361