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 18:30
How often does colleges update the cost of attendance on their website? . a)every two years b) every four years c) every year d) every semester
Answers: 1
question
Computers and Technology, 23.06.2019 18:50
What is transmission control protocol/internet protocol (tcp/ip)? software that prevents direct communication between a sending and receiving computer and is used to monitor packets for security reasons a standard that specifies the format of data as well as the rules to be followed during transmission a simple network protocol that allows the transfer of files between two computers on the internet a standard internet protocol that provides the technical foundation for the public internet as well as for large numbers of private networks
Answers: 2
question
Computers and Technology, 24.06.2019 10:00
Which feature of a blog to restore and retrieve older post
Answers: 3
question
Computers and Technology, 24.06.2019 16:00
Which of the following characters is acceptable to use in a filename? ? / – %
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
Mathematics, 22.02.2020 21:40
question
Mathematics, 22.02.2020 21:42
question
Mathematics, 22.02.2020 21:56
question
Mathematics, 22.02.2020 21:56
question
Mathematics, 22.02.2020 21:56
question
History, 22.02.2020 21:56
question
Mathematics, 22.02.2020 21:57
question
History, 22.02.2020 21:57
Questions on the website: 13722367