





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?
base(number, "Savings", balance) { } } Which of the following statements creates an object of the Account class? - 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.
MessageBox.Show("Print"); p.Print(); } } public class Order : IPrintable { public void Print() { MessageBox.Show("Order"); } } 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