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, 21.06.2019 22:00
3. (6 pts) internally in the computer, with few exceptions, all numerical computation is done using binary numbers. output, however, often uses ascii, which is formed by appending 011 to the left of a bcd code. thus, an algorithm that directly converts a binary integer to a bcd integer is very useful. here is one such algorithm 1) draw lines to the left of the binary number to bound the expected bcd decades. (each decade is a group of 4 bits.) move the binary number one bit to the left. add 0011 to each bcd decade containing a binary value> 0100 repeat steps 2-3 until the last bit in the binary number has been moved into the least significant decade position. (note that when the last bit has been shifted into bcd decade, step 3 is not repeated.) read the bcd result. 2) 3) 4) 5) a) execute the algorithm for the binary number 1101101 b) execute the algorithm for the binary number 01110101110 4. (4 pts) represent the decimal number 3568 in bcd; excess-3 code; ascil; and hex.
Answers: 1
question
Computers and Technology, 23.06.2019 21:30
Write a fragment of code that reads in strings from standard input, until end-of-file and prints to standard output the largest value. you may assume there is at least one value. (cascading/streaming logic, basic string processing)
Answers: 3
question
Computers and Technology, 23.06.2019 23:30
What are "open-loop" and "closed-loop" systems
Answers: 1
question
Computers and Technology, 24.06.2019 08:30
Intellectual property rights are exclusive rights that protect both the created and the creation. ipr offers exclusively what benefits to the person or people covered by it
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
English, 11.10.2020 14:01
question
Chemistry, 11.10.2020 14:01
question
Mathematics, 11.10.2020 14:01
Questions on the website: 13722360