Learn to type variables to various different classes. First, you can type a variable to a single class. Next, you can type a variable to a superclass, which allows any subclass to be used for the variable. Finally, you can categorize classes using interfaces. Interfaces define methods that are present with any class that implements the interface. As a result, you can type a variable to the interface and any class that follows the interface rules can be assigned to the variable.
- When you create a variable it has to have a type.…Either you define the type…or it's inferred by the value that is being assigned to it.…When you have a variable that has a type…you define the type based on a class.…Remember, since everything is a class…that means integer, Boolean, string,…and everything else that we used before…to define a variable is also a class.…So if we create a variable that accepts integers…we are typing that variable using the integer class.…
We can type variables to be any object we want,…including objects based on classes that we create ourselves.…So if I take a variable and set it to the cat type…I can create an instance of a cat class…and assign it to the variable.…But what if I wanted to assign a fish to the variable?…Because it is specifically typed to a cat…I can't take an instance of a fish class and assign it.…There is a way to deal with this.…Instead of typing to a cat…I can type the variable to the super class, animal.…
Since, by the definition of the class,…a cat and a fish are both animals…
Join Doug Winnie as he explains the principles of programming and helps you connect to core concepts by exploring three ways that programmers perform their jobs. Doug starts by sharing the history of coding and then dives into functions, values, variables, and parameters used to define actions. He covers capturing input from users, creating conditional tests, using loops with arrays, and object-oriented programming basics. He also takes you beyond programming, into processes like debugging, refactoring, and building iteratively.
- Working with values and variables
- Breaking down tasks
- Customizing functions and parameters
- Building conditional tests
- Creating and changing arrays
- Working with objects and classes
- Debugging and refactoring code
- Going beyond the code as a programmer
Skill Level Beginner
1. Control Computers with Code
2. Define Actions Using Code
3. Repeat Actions and Test for Conditions
4. Objects and OOP
5. Beyond Programming
Debug problems2m 50s
Next steps1m 19s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.