Objects

Description

Flashcards for the Objects unit of the SSD AS level course from CCEA.
Ruth Hyndman
Flashcards by Ruth Hyndman, updated more than 1 year ago
Ruth Hyndman
Created by Ruth Hyndman almost 9 years ago
10
0

Resource summary

Question Answer
Define and describe an object. - An instance of a class with a block of memory allocated. - The base type for all derived classes. - Can be stored in a named variable or an array/collection. - All objects have states and behaviours. - Variables define states - Methods define behaviour
What is a class and what does it do? - A set of related fields and methods detailing how to construct an object. - Defines the data and behaviour of a type. - EXAMPLE
What is a constructor and what does it do? How does it differ from a method? - A special method declaration invoked when creating a new object. - It sets up any logic needed for an object - Different from a method: > No return type > Has to have the same name as the class > Enables creation of own custom types by grouping together variables of other types, methods and events.
What is overloading? - When a subclass defines a method with the same name as one in its super class with differences in the arguments (different order/type). - Objects from the subclass have access to both. - The program will automatically detect which method you are calling by looking at the arguments you are passing to the method.
What is overriding? The ability to modify the super class's behaviour in the subclass. A method of the same name and signature can be written with modifications in the subclass and be invoked by an object of that type. C# suggests 'new' should be applied to the modified method. The superclass method can be invoked by the use of 'base.method name()'.
What is a method? And describe its structure. <Access Specifier><Return Type><Method Name>(Parameter List) { Method Body } Access Specifier - determines the visability of a variable or a method from another class Return Type - data type of the value that will be returned by the method (may be void) Method Name - Unique identifier for method, case sensitive, cant be same as any other identifier, should be meaningful Parameter List - used to receive input to the method, optional but you need the ()
What is Encapsulation? *SEE KEY TERMS*
Define an access modifier and give examples? Keywords that are used to define the accessibility of a method or variable. + *SEE KEY TERMS* + • Internal – access is limited to classes within the current assembly (same .dll/ project).
What is the rule of thumb for naming conventions? A useful rule of thumb classes is: • Make variables private. • Make methods public. • Make your methods public, if you don’t want anyone outside of the current class to see this method. i.e. it’s a specific implementation detail to that class.
What is polymorphism? • Polymorphism allows classes to transform into a different class within its inheritance hierarchy. • Polymorphism comes from the Greek meaning "having multiple forms“ and is the characteristic of being able to assign a different meaning or usage to something in different contexts - specifically, to allow an entity such as a variable, a function, or an object to have more than one form. It allows a programmer to use objects of different types but treat them in their "general" form while maintaining their specific functionality.
What are getters and setters? • Use getters and setters. A Getter is a public method that is used to return the value of a private variable in a class. • A setter is a public method that is used to set a private variable within a class.
What is the main benefit of using classes in OOP? • The use of classes in object-oriented programming allows for great reusability. • Classes usually do one specific thing and should be named to suit its purpose. For example, a Bicycle class represents a class of Bicycles. A Dog represents the class of dog animals. Once we have written a class, we can make create instances of this class (known as objects). Other objects can interface with the objects we have created, to invoke functionality that they have defined.
Describe how you would call a method/what calling a method does. Methods exist to be called. You call a method by name to ask it to perform a task. If the method requires information (as specified by its parameters) you must supply the information requested. If the method returns information (as specified by its return type), you should arrange to capture this information.
STATIC Static - only one copy exists in memory and client code can only access it through the class itself. - Not Static - client code can use it by creating objects or instances which are assigned to a variable
Show full summary Hide full summary

Similar

Exception handling
Ruth Hyndman
Data Structures - Sorting and Searching
Ruth Hyndman
Control Structures - no methods
Ruth Hyndman
Data Structures
Ruth Hyndman
File Handling/Managing Input/Output
Ruth Hyndman
Business Studies Unit 1
kathrynchristie
Business Studies Unit 1
emily.mckechnie
GCSE Physics Revision notes
Megan McDonald
Memory & Storage
Ben Fellows
Label the Classroom
Robert Caceres
OOP (Object Oriented Programming)
Adam Cook