





Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!






When used correctly, inheritance can - correct answer ✅simplify the overall design of an application In the System.Windows.Forms namespace, the Control class - correct answer ✅provides properties and methods that all controls in the namespace have in common The ToString, Equals, and GetHashCode methods are available to all objects because - correct answer ✅they are members of the System.Object class, which all objects inherit A protected method defined within a base class is available to - correct answer ✅both the base class and classes derived from it If the Student class inherits the Person class and overrides a virtual method named GetBirthday, what feature does the following code example illustrate? Student s = new Student("Albert Einstein"); Person p = s; p.GetBirthday(); - correct answer ✅Polymorphism If the Student class inherits the Person class and overrides a virtual method named GetBirthday, which method does the third statement in the following code example call? Student s = new Student("Albert Einstein"); Person p = s; p.GetBirthday(); - correct answer ✅the GetBirthday method defined in the Student class
The GetType method of an object returns - correct answer ✅a Type object that contains information about the object's type If the Student class inherits the Person class, which of the following statements is true? - correct answer ✅You must explicitly cast a Person object to a Student object whenever a Student object is expected. Which of the following declarations defines a Student class that inherits a Person class? - correct answer ✅public class Student : Person A class can - correct answer ✅be both a base class and a derived class Which of the following method declarations overrides the method that follows? protected virtual double CalculateMilesPerGallon(double speed){...} - correct answer ✅public override double CalculateMilesPerGallon(double s){...} (Refer to diagram 14-1.) If the constructor that follows is called, what other constructor is also called? public Sailboat(string id, decimal length, int sails) : base(id, "sailboat", length) { this.sails = sails; } - correct answer ✅CHECK
public class SavingsAccount : Account { public SavingsAccount() : base() { base.Type = "Savings"; } public SavingsAccount(int number) : base(number) { base.Type = "Savings"; } public SavingsAccount(int number, decimal balance) : base(number, "Savings", balance) { } } (Refer to code example 14-1.) If the statement that follows is executed, which of the following constructors will be called? SavingsAccount account = new SavingsAccount(111); - correct answer ✅public Account(int number){...}
If a method accepts an Object type, what types of objects can it accept? - correct answer ✅All objects Which of the following is not a reason to declare a class as sealed? - correct answer ✅To give a class more functionality Which of the following can you not code in a subclass? - correct answer ✅A call to a private method of the base class Assume that the Vehicle class contains a virtual method named CalculateMaxSpeed. Assume that both the MotorVehicle and Automobile classes override this method. Which class defines the method that is called when the second statement in the code that follows is executed? - correct answer ✅Automobile Which of the following statements about interfaces is not true? - correct answer ✅A class can only implement a single interface. Which of the following is a difference between interfaces and abstract classes? - correct answer ✅None of the members of an interface can be implemented, but some of the members of an abstract class can be. Which of the following declares a class named Student that inherits a class named Person and implements the ICloneable interface? - correct answer ✅public class Student : Person, ICloneable Given an interface named IWriteable, what type of object can be passed to the Save method with the following declaration?
public class Transaction { } public class Rental : Transaction, IPrintable { public void Print() { MessageBox.Show("Rental"); } } (Refer to code example 15-1.) Which of the following statements will definitely not compile? - correct answer ✅IPrintable p = new IPrintable(); (Refer to code example 15-1.) What happens when the code that follows is executed? Rental r = new Rental(); Printer.Print(r); - correct answer ✅"Print" is displayed in a message box and then "Rental" is displayed in a second message box. (Refer to code example 15-1.) What happens when the code that follows is executed?
Order order = new Order(); order.Print(); - correct answer ✅"Order" is displayed in a message box. A method that accepts an interface as an argument can accept any object that - correct answer ✅implements that interface A variable that stores an object that implements an interface can be declared as which of the following data types? - correct answer ✅The class that defines the object The interface that the object implements Any subclass of the class that defines the object All of the above The ICloneable interface defines a Clone method that - correct answer ✅returns an object type The IComparable<> interface defines a CompareTo method that - correct answer ✅accepts a specific type as a parameter The main reason for creating a class that implements the IEnumerable<> interface is so the class can - correct answer ✅be used with a foreach statement