subject

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 ) );

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 06:00
How can a user delete a drawing object
Answers: 1
question
Computers and Technology, 23.06.2019 07:30
What part of the interface displays the external references contained in a selected cell? the status bar the review tab the scroll bar the formula bar
Answers: 1
question
Computers and Technology, 24.06.2019 16:50
How many types of string types does python support?
Answers: 1
question
Computers and Technology, 25.06.2019 03:30
Kou converged his word document to a powerpoint document. when he received the powerpoint, he was missing material. which most likely explains why the material was missing? a it did not have a proper heading b he incorrectly copied and pasted it c he did not save his document properly d there was not enough space in powerpoint
Answers: 1
You know the right answer?
A. Show the output of the following program: 1: public class Test { 2: public static void main ( Str...
Questions
question
Social Studies, 22.09.2019 09:00
question
Mathematics, 22.09.2019 09:00
Questions on the website: 13722360