An interface is designed to represent an athlete. An athlete has a name and a sp
ID: 3807611 • Letter: A
Question
An interface is designed to represent an athlete. An athlete has a name and a sport. The class heading is as follows. public interface Athlete Which of the following will result in a compiler error if included in the interface. private String myname; private String mySport; public Athlete (string name, string sport)} myName = name; mySport = sport; public string getName (); public string getsport e (); a. I and II only b. I, II, III c. III only d. Only e. II only Which of the following pairs is not inheritance (is-a) relationship? a. Student, Person b. Car, Vehicle c. Car, Tire d. Sedan, Car e. Violin, Instrument Which of the following expressions tests whether the object cat belongs to the type Animal? a. (cat belongsTo Animal) b. (cat instanceof Animal) c. cat implements Animal d. (Animal contains cat) e. (Animal instanceof cat) Suppose an Employee class contains a method setName to set the value of an Employee object's instance variable name, plus a method getName to access the value of name. Consider the following code fragment: Employee e1 e2; e1 = new Employee (); e2 = new Employee (); e1. setName ("Sally"); e2. setName ("Jane"); e2 = e1; e2. setName ("Martha"); System. Out. printIn (e1. getName ()); What would be displayed on the console? a. Sally b. Jane c. Martha d. nullExplanation / Answer
Question 11:
Answer: c) Martha
Employee e1 object name is Sally
Employee e2 object name is Jane
When we use this statement e2 = e1, all properties of e1 is assigned with e2. So when we do any modification on e2 object that will reflect in e1 objet as well. So we set e2 object name as "Martha" so when we use this sttaement e1.getName() that will return "Martha".
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.