1 / 15

Introduction to Object-Oriented Programming: Key Concepts and Examples

Learn about objects, classes, attributes, methods, and more in object-oriented programming. Explore how to manipulate object instances and understand the state and behavior of a class.

Download Presentation

Introduction to Object-Oriented Programming: Key Concepts and Examples

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Re-Intro to Object Oriented Programming Prof. Elizabeth Adams

  2. What are objects? • Objects are classes • For example, we can have a Car object also known as a Car class • The Car class has attributes or fields that belong to every existing car • For example: • Serial number • Color • Maker • Number of doors

  3. What do you call a particular object? • an instance of the class • Each instance of the class will have all of the attributes of the class

  4. What does a class consist of? State – which is reflected in its attributes Behavior – which is reflected in its actions carried out by its methods

  5. How do you create an instance of a class? You use the new operator

  6. Can you have more than one instance of a class? yes

  7. How do you manipulate object instances By calling or invoking methods aka functions or we can pass messages

  8. What do methods consist of? Header (name and a parameter list which MAY be empty) and a body

  9. What are parameters? “stuff” that the methods need to pass additional values into the object instance or content of the messages that are being passed to the object instance

  10. What is the signature of a method? What everyone agrees is part of the signature is the method (function) name, number, type and order of parameters. What others include is the return type. We have been using the 1st definition and calling the 2nd definition the method header

  11. Can you re-use (concurrently) method names? Yes, as long as either the number, type or order of the parameters is different.

  12. What kinds of methods are there? • Constructor – creates a new object instance • Accessor – return information about the state of an object instance • Mutator – changes the state of an object instance

  13. What is state? The “condition” of its attributes

  14. How can you determine state? By using its accessor methods In BlueJ – using the Inspector window

  15. When we talk about attributes of the class, what is the other name we use? Instance variables or fields or properties

More Related