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 08:00
Michael has written an e-mail to his employees that describes a new product special that will be introduced to the customers next week. by taking time to make sure the e-mail is well written, logical, and organized, michael has made sure his message has the characteristics of a) effective communicationb) ineffective communicationc) barriers to communicationd) workplace communication
Answers: 2
question
Computers and Technology, 23.06.2019 09:30
[java] create an application called registrar that has the following classes: a. a student class that minimally stores the following data fields for a student: - name - student id number - number of credits - total grade points earned and this class should also be provides the following methods: - a constructor that initializes the name and id fields - a method that returns the student name field - a method that returns the student id field - methods to set and retrieve the total number of credits - methods to set and retrieve the total number of grade points earned. - a method that returns the gpa (grade points divided by credits) b. an instructor class that minimally stores the following data fields for an instructor: - name - faculty id number - department the following methods should be provided: - a constructor that initializes the name and id fields - methods to set and retrieve the instructor’s department. c. a course class that minimally stores the following data for a course: - name of the course- course registration code- maximum number of 35 students- instructor- number of students- students registered in the course (an array)the following methods should also be provided: - a constructor that initializes the name, registration code, and maximum number of students- methods to set and retrieve the instructor- a method to search for a student in the course; the search should be based on an id number.- a method to add a student to the course. if the course is hill, then an exception with an appropriate message should be raised (try creating your own exception class for this). also, be sure that the student is not already registered in the course. the list of students should be in the order that they registered.- a method to remove a student from the course. if the student is not found, then an exception with an appropriate message should be raised (use the same exception class mentioned a method that will allow course objects to be output to a file using object serialization- a method that will allow course objects to be read in from a file created with object serializationyou will note that the student and instructor classes described above have some commonality. create aperson class that captures this commonality and uses it as a base class for student and instructor. this class should be responsible for the name and id fields and also provide atostring method that returns a string of the form name, id. this will be the inheritedtostring method for the student and instructor classes.1. draw a uml diagram for diss application.2. implement the previous classes in java. write a main program that can serve as a test class that tests all of the methods created and demonstrates that they are working
Answers: 2
question
Computers and Technology, 24.06.2019 03:30
It is not necessary to develop strategies to separate good information and bad information on the internet. true or false
Answers: 1
question
Computers and Technology, 24.06.2019 10:40
Joe needs to see the slide transitions and animations he has applied to his slides in a large view. which presentation view should he use? in which tab would joe find the animations option to make further changes, if any?
Answers: 1
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, 27.10.2020 02:20
question
Computers and Technology, 27.10.2020 02:20
question
English, 27.10.2020 02:30
question
Mathematics, 27.10.2020 02:30
question
Mathematics, 27.10.2020 02:30
question
Mathematics, 27.10.2020 02:30
Questions on the website: 13722363