From the course: Computer Science Principles: Programming

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Work with existing classes and objects

Work with existing classes and objects

From the course: Computer Science Principles: Programming

Start my 1-month free trial

Work with existing classes and objects

- As a programmer, you will work with pre-built classes that are part of the programming language and SDK or Software Development Kit that you'll be working with. For instance, you might be working with a button component that is part of iOS, Android, Windows, HTML, or another technology. That button is an object, just like any other and is defined by a class. When you create your instance of a class, you instantiate it and the code in the constructor runs. The constructor is helpful if you need to set things up in the instance when it runs. When you work with an instance, you will access properties and methods inside it, defined by the class, using the instance name. This is done by taking the instance name of the object and then access the property or method. To modify a property, you'll use the property name and use the assignment operator to assign a value to the class instance property. To use a method, you will use a method name just like any other function you would write and…

Contents