• Shuffle
    Toggle On
    Toggle Off
  • Alphabetize
    Toggle On
    Toggle Off
  • Front First
    Toggle On
    Toggle Off
  • Both Sides
    Toggle On
    Toggle Off
  • Read
    Toggle On
    Toggle Off
Reading...
Front

Card Range To Study

through

image

Play button

image

Play button

image

Progress

1/27

Click to flip

Use LEFT and RIGHT arrow keys to navigate between flashcards;

Use UP and DOWN arrow keys to flip the card;

H to show hint;

A reads text to speech;

27 Cards in this Set

  • Front
  • Back

When you develop an application using athree-layer architecture, the layer that provides the user interface is calledthe ________________ layer.

Front End, Middle Tier, Back End

If you code a get accessor for a property butyou don’t code a set accessor, the property will be a ________ property.

Static

Static methods can be called without creatingan instance of a ___________.

Class

Astructure is similar to a class but it defines a _____________ type.

Public

Code a statement that creates an instance ofan Account class using the default constructor and stores the object that’screated in a variable named account.

Account account = new Account();

Two objects created from the same class canhave different


a. fields


b. methods


c. data


d. properties

D. Properties

Whichof the variables declared in the following class is an instance variable?


public classCustomer


{


public string firstName;


private static int count;


public string GetDisplayText()


{ string displayText = firstName + count; return displayText;


}


}


a. firstName


b. count


c. displayText

A. firstName

When you’re entering the C# code for a formand want to refer to a static method in another class, you start with


a. the name of the class that contains it


b. the name of an object created from the class that contains it


c. the name of the method

A.

To declare an indexer, you code the____________ keyword followed by the brackets that contain the parameter thatdefines the index.

this

Ifyou overload the == operator, you must also overload the _______ operator.

!=

public classCustomerList


{ private List customers; public delegate voidChangeHandler(CustomerList customers); public event ChangeHandler ChangedList; public CustomerList()


{ customers = new List(); }


public void Add(Customer c) { customers.Add(c); }


public static CustomerList operator +(CustomerList customers, Customer c)


{ customers.Add(c);


return customers; }}

(Referto code example 13-1) Write the code for activating the event that’s declaredfor the CustomerList class. Assume that you’re going to add this code to theAdd method.




Ans: ChangedList(CustomerList)

Whencoding a business class, why would you want to throw an argument exception froma property or method?


a. So the business class is completely self-contained and doesn’t depend on classes that may be coded by other programmers to validate data


b. So the user interface classes don’t have to validate data


c. Because it’s more efficient to throw an exception than to validate data before passing that data to a business class


d. Because it makes your code easier to read f


A

Whenyou code a statement in a form class that uses a property that throws anargument exception if the argument that’s passed to it is invalid, you should


a. use a try-catch statement to catch the exception that’s thrown


b. rely on the property’s data validation


c. validate the argument before it is passed to the property so the exception is never thrown d. use a delegate to refer to the exception handler for the argument that’s thrown

C


If you are designing the classes for anapplication and you realize that two classes share some common elements, youcan define those elements in a ____________ class.

base class

Polymorphism is a feature of inheritance thatlets you treat objects of different subclasses that are derived from the samebase class as if they had the same ____________ as the base class.


Type

Aprotected method defined within a base class is available to


a. only the base class


b. only classes derived from the base class


c. both the base class and classes derived from it


d. neither the base class nor classes derived from it

C

Ifthe Student class inherits the Person class and overrides a virtual methodnamed GetBirthday, which method does the third statement in the following codeexample call?


Student s = newStudent("Albert Einstein");Person p = s;


p.GetBirthday();


a. the GetBirthday method defined in the Person class


b. the GetBirthday method defined in the Student class


c. the GetBirthday method defined in the Object class


d. none of the above

B

Aclass can


a. have only one derived class


b. be the base class for only one derived class


c. be only a base class or a derived class


d. be both a base class and a derived class

D

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
cod...

Assumethat 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 thecode that follows is executed?


MotorVehicle car = new Automobile();car.CalculateMaxSpeed();


a. Automobile


c. Vehicle


b. MotorVehicle


d. Object





A

Write the declaration for a class named Bookthat implements the ICloneable and IDisplayable interfaces

publicclass Book : ICloneable, IDisplayable

Whichof the following statements about interfaces is not true?


a. An interface can only declare abstract members.


b. An interface can inherit other interfaces.


c. A class can only implement a single interface.


d. A class that implements an interface must provide an implementation for every member of the interface.

C

Givenan interface named IWriteable, what type of object can be passed to the Savemethod with the following declaration?


public bool Save(IWriteable obj)


a. any object


b. any object that implements the IWriteable interface


c. any object that implements the Save method


d. only objects created from the IWriteable class

B

Amethod that accepts an interface as an argument can accept any object that


a. implements that interface


b. defines the same methods as the interface


c. implements the interface or defines the same methods as the interface


d. is created from that interface

A

Ifyou implement the ICloneable interface for an Invoice that has a property thatrepresents a Customer object


a. you must make sure that the clone refers to a different Customer object


b. you must make sure that the clone refers to the same Customer object


c. you must convert the Customer object to its composite value types


d. you can decide whether the clone refers to the same or a different Customer object

D

Codea using directive for the Invoice class and any other classes in the samenamespace as the Invoice class that follows.


namespace Payables


{ namespace Business


{ public class Invoice


{ // code for the Invoice class goeshere }


}


}

;

Howwould you refer to the nested class in the following example from anotherclass?


public classCustomer


{ public class Address { }}


a. Address


c. Customer_Address


b. CustomerAddress


d. Customer.Address.

D

Partialclasses can be used to


a. split the code for a class across two or more namespaces


b. split the code for a class across two or more files


c. hold the code for a class that hasn’t been finished


d. hold the code for a class until the other classes in that assembly are finished

B