Types and Classes Flashcards
What are the two kinds of types in programming?
Built in User defined (for object oriented programming)
What is a class?
Defines a type and allows the creation of new types
What is an object?
An instance of a class
What is the construct to instantiate (create) an object?
Type ObjectIdentifier = new Type(); i.e Employee John = new Employee();
What is a method?
A method takes in parameters and does something with those values
What is a public vs private class or method?
Public is accessible by anywhere in the code
Private is only accessible by within the same class
What are the 3 attributes of classes?
Fields
Properties
Methods
What are properties of a class?
Inherently public; used to store values
What are fields of a class?
Inherently private, only can be accessed by methods of the class; used to store values
What is camelCase vs PascalCase?
camelCase uses lowercase first letter
PascalCase uses uppercase first letter
What syntax uses camelCase?
Fields, Variables, Parameters (myValue)
What syntax uses PascalCase?
Class, Constants, Properties (MyValue)
What is polymorphism?
Derived class overrides the inherited behaviour of the base class
How is polymorshpism implemented?
Create virtual method in parent(base) class and modify it in the derived class by specifying override
What is encapsulation?
Allows classes to hide their implementation through using access modifiers to deny access to members of a class
What is an overloaded constructor?
A procedure that is automatically invoked with the instantiation of an object, overloaded means it accepts parameters
What is a default constructor?
A procedure that is automatically invoked with the instantiation of an object, default has no parameters and can’t change
What is the single inheritance model?
A class can inherit from one base class Standard supported in .NET Framework
What access does public access modifier give?
Type or member can be accessed by any other code in assembly and othe rassemblies
What access does private access modifier give?
Type or member can only be accessed by code in the same class or struct
What access does protected access modifier give?
Type or member can only be accessed by code in the same class or in a derived class
What access does internal access modifier give?
Type or member can be accessed by any code in the same assembly, not from another
What access does protected internal access modifier give?
Type or member can be accessed by any code in the same assembly or derived class in another assembly
What is the difference between a constructor and a method?
Constructor is run implicitly once with new object, Method is explicitly called
Constructor has same name as class