introtoOOP.pdf - 361 Lesson 2 Introduction to...

This preview shows page 1 - 5 out of 21 pages.

1. abstract: A class that does not provide a complete implementation must be declared with the keyword _________. 2. Abstract Classes: 1. The _________ ________ provide a common definition of a base class that can be shared by multiple derived classes. 2. The ___________ _______ often provides incomplete implementation. 3. To instantiate an _________ ______ you must inherit from it and complete its implementation. abstract class Polygon { public double Length { get; protected set; } public double Width { get; protected set; } abstract public double GetArea(); } class Rectangle: Polygon { public Rectangle(double length, double width) { Length = length; Width = width; } public override double GetArea() { return Width * Length; } } 3. Access modifier: internal: Access is restricted to the code in the same assembly. 4. Access modifier: private: Access is restricted to the containing class. 5. Access modifier: protected: Access is restricted to the containing class and to any class that is derived directly or indirectly from the containing class. 6. Access modifier: protected internal: A combination of protected and internal that is, access is restricted to any code in the same assembly and only to derived classes in another assembly. 7. Access modifier: public: Access is not restricted. 8. accessors: A property has two ______________, get and set. The get _______ is used to return the property value, and the set ____________ is used to assign a new value to the property. 9. Answer: a Section Reference: Understanding Access Modifiers The private modifier restricts the access to the class in which the member was defined. The protected modifier restricts the access to the containing class and to any class derived directly or indirectly from the containing class. The internal modifier restricts the access to the code in the same assembly. The public modifier does not restrict access.: You are developing code for a method that calculates the discount for the items sold. You name the method CalculateDiscount. The method defines a variable, percentValue of the type double. You need to make sure that percentValue is accessible only within the CalculateDiscount method. What access modifier should you use when defining the percentValue variable? a) private b) protected c) internal d) public 361 Lesson 2 Introduction to Object-Oriented Programming Study online at quizlet.com/_32f36h
Image of page 1

Subscribe to view the full document.

10. Answer: a Section Reference: Understanding Inheritance Use the sealed keyword to define the Scenario class. When applied to a class, the sealed modifier prevents other classes from inheriting from it.: Suppose that you defined a class Scenario that defines functionality for running customized pivot transform on large data sets. You do not want the functionality of this class to be inherited into derived classes. What keyword should you use to define the Scenario class? a) sealed b) abstract c) private d) internal
Image of page 2
Image of page 3

Subscribe to view the full document.

Image of page 4
Image of page 5

{[ snackBarMessage ]}

Get FREE access by uploading your study materials

Upload your study materials now and get free access to over 25 million documents.

Upload now for FREE access Or pay now for instant access
Christopher Reinemann
"Before using Course Hero my grade was at 78%. By the end of the semester my grade was at 90%. I could not have done it without all the class material I found."
— Christopher R., University of Rhode Island '15, Course Hero Intern

Ask a question for free

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern