Computer Science AP Java Video Course

atomictoddler.com -   [index]     [Page 2]     [Page 3]     [Page 4]     [Page 5]  

***UPDATE - I had to move the videos for this course to a new YouTube channel.
***Please access the videos from this new channel from now on
***and share, subscribe, and watch as much as you can with others!
***I will be deleting the old channel very shortly!
*** https://www.youtube.com/channel/UCw2zv1zmT5ak5olBgB7IqmA


20 INTRODUCTION TO INHERITANCE

This is a big topic in Object Orientated Programming languages. Instead of learning new classes and commands, this section is going to focus on how you can set up relationships between classes and build upon classes that you or someone else has already coded. There is alot to learn in this and the following sections. It is a major theme of the course and an important one to understand, especially if you are considering continuing learning more about programming after this course! Lets get started.

Legal Disclaimer - "READ THIS!"
Sections 20,21,22,23 attempt to give you an overview of the inheritance and polymorphism. They cover the basics and purposely omit many details. The purpose of this particular course is to introduce you to the ideas here so you know enough to continue learning more on your own. If you want to know more about this topic, go online and start hunting down all the finer points, discussions, sample code, etc.

Open the Project 'InheritanceExamples'
This and the next few sections will use example code from the project 'InheritanceExamples'. Everything you see in the videos is from this project folder and you should have it open so that you can pause the video at times and examine the classes. By the end of the unit, this project folder will be an excellent reference to look back on since it will contain all the concepts of this massive unit.

Visit Oracle's Java Tutorials
https://docs.oracle.com/javase/tutorial/java/IandI/index.html
This is the address to Oracle's Java Tutorials series. It is a really good online textbook for many of the topics that I will introduce you to. Keep this webpage bookmarked so that you can read their tutorials on a topic when the video seems confusing or you just need a different explanation of the topic. Remember that you have the textbook/s available as well!

Watch - "Inheritance Introduction"
Inhertiance offers the programmer many oportunities when it comes to creating relationships between classes and code. In this video we will learn one of the most basic ways to use inheritance, which is extending classes.

Review/Practice Questions - "InheritanceBigWorksheet"
Open the document InheritanceBigWorksheet.doc from the documents folder. This document has a short set of review/practice questions that follow the videos in this section. Have this document open while working on this section. After watching the appropriate video/s you can answer the questions directly into the word document.

Watch - "Inheritance Fields"
A subclass will 'get' all the fields (variables) of it super class but it can only 'use' the fields declared as public and protected. The private fields are not useable by the subclass. They say that the public and protected member variables are inherited and that the private member variables are not inherited. This video talks about the access level of fields when extending classes.

Watch - "Inheritance Methods"
Just as fields can be inherited, so can methods with the proper access modifiers. You are also free to add new methods to your subclass.

Review/Practice Questions - "InheritanceBigWorksheet"
Complete the questions for the previous two videos.

Watch - "Inheritance Overriding"
You can inherit methods in your subclass. You can create new methods in your subclass. You can also 'override' methods in your subclass. Overriding is when you re-write a method that already exists in a class you are extending - keep the same method signature but write a different implementation (way it's coded). Watch to learn!

Review/Practice Questions - "InheritanceBigWorksheet"
Complete the questions for the previous video.

Code It - "InheritanceBigWorksheet RandomBug.java"
One of the questions on the worksheet for the overriding topic asked you to code RandomBug.java and test it out. Actually code this bug and test it out! A good example of how extending a class and overriding a method can save you time and make good use of existing code.

Watch - "Inheritance Constructors"
So you're going to extend a class but you want the new class to have a constructor. There a bunch of rules and ideas you have to learn about so that you write your constructor the correct way. This video will disucss a few of the key points you have to know about. A main point of this video will be the use and rules associated with the keyword 'super()' in your constructor code.

Watch - "Inheritance Overrided Methods in the Constructor"
Not that you are writing constructors for your extended classes you have to be aware of how any overrided methods will behave.

Watch - "Inheritance Calling Methods from Superclass"
Sometimes you might want to use a method from your superclass (the class you extended). Here's a short video to show you how. It will introduce you to one use of the keyword 'super'.

Review/Practice Questions - "InheritanceBigWorksheet"
Complete the questions for the previous three videos that focus on constructors.

Watch - "Inheritance Quick Review of Rules"
Just a quick video that takes a look at some of the facts about inheritance that we have looked at so far.

 

21 INTRODUCTION TO POLYMORPHISM

Polymorphism is the ability of an instance/object to take on various forms. This is much easier to demonstrate with code! Now that you know how to create subclasses and start using inheritance you need to know what polymorphism is and how your projects can benefit from using it.

Open the Project 'InheritanceExamples'
This section continues to use the same project from the previous section, so you probably already have it ready and waiting.
Remember that pausing the video and actively reading the code can be a good way to try to figure out what is going on!

Visit Oracle's Java Tutorials
https://docs.oracle.com/javase/tutorial/java/IandI/index.html
Just a friendly reminder that the tutorials cover this topic with examples. If the videos aren't working for you, try out these online tutorials.

Watch - "Polymorphism Introduction"
In this video we will look at some of the basic surrounding polymorphism. You'll hopefully start to get an idea of what is meant by poly (many) morphism (changing). A main concept in this video will be the classic IS-A relationship between classes.

Review/Practice Questions - "PolymorphismWorksheet"
Open the document PolymorphismWorksheet.doc from the documents folder. This document has a short set of review/practice questions that follow the videos in this section. Have this document open while working on this section. After watching the appropriate video/s you can answer the questions directly into the word document.

Watch - "Polymorphism Rules About Methods"
Yes, more rules about what you can do and cannot do and when and how to do it. Main ideas in this video include knowing which methods a field can call, how to cast, what the compiler will allow and why, and what run times errors can occur with casting.The good news is that there is a logic to the rules and you shouldn't have to do too much memorizing. Seek to understand the rules - not memorize!

Review/Practice Questions - "PolymorphismWorksheet"
Complete the questions for the previous video.

Watch - "Polymorphism In Action 01"
Lets take a look at our PersonTeacherStudent example from before and see how we can use a little bit of this polymorphism to complete some common tasks. Big ideas in this video are applying the IS-A relationship to creating fields,lists, parameters, and return types that are more flexible with regards to reference type.

Watch - "Polymorphism In Action 02"
A continuation of the previous example. Big ideas include using the correct field type, casting, and using the keyword 'instanceof'. Must watch!

Review/Practice Questions - "InheritanceBigWorksheet"
Complete the questions for the previous two videos.

 

22 INHERITANCE and ABSTRACT CLASSES

Your first introduction to inheritance was extending an existing class. Another way to inherit code is to extend an 'abstract' class. This short section is about abstract classes and when you might create them.

Open the Project 'InheritanceExamples'
Same one you've been using. Don't close it!

Watch - "Abstract Classes 01"
What's an abstract class? What is an abstract method? How do you extend a class that is abstract? When might you include an abstract class in your projects? This video will focus on Shapes, Circles, Parallelograms, etc. as an example to explain. Enjoy.

Watch - "Abstract Classes 02"
This video takes our old Student / ExchangeStudent example and re-organizes the classes to make use of abstract classes. It will emphasize the use of abstract classes but more importantly will show you that different programmers might decide on different ways to form relationships between their classes (we are taking the old project and doing it a different way). At the end of the video you can ask yourself if you prefer the original project relationships or the new one.

Review/Practice Questions - "AbstractClassesWorksheet"
Open the document AbstractClassesWorksheet.doc from the documents folder. Complete the worksheet.

 

23 INHERITANCE and INTERFACES

You know that an abstract class usually consists of some methods that are implemented and some methods that are declared abstract (not implemented). An interface is usually the extreme of this and doesn't implement any of the methods. The role of the interface is significantly different in that you don't extend interfaces, you 'implement' them.

Open the Project 'InterfaceExamples'
Not the same project as before! This project contains several examples involving Interfaces.

Watch - "Interfaces Introduction"
The remote control car example project will help walk us through the structure of an interface, how to implement it, and how it is used in this example. The overall rules presented here are quite simple - interfaces are easy to create and implement.

Review/Practice Questions - "InterfacesWorksheet"
Open the document InterfacesWorksheet.doc from the documents folder. This document has a short set of review/practice questions that follow the videos in this section. Have this document open while working on this section. After watching the appropriate video/s you can answer the questions directly into the word document.

Watch - "Interface List"
The List Interface is a very popular interface used by Java programmers and is a key topic for the interface section of the AP course. Check out how interfaces have made the List Interface popular and easy to use.

Review/Practice Questions - "InterfacesWorksheet"
Complete the questions for the previous video.

Watch - "Interfaces Tagging"
Fairly short video that shows another use of interfaces. Not a very important use or one that is tested on the AP Exam, but worth presenting.

Watch - "Interfaces Event Example"
Here's a great example of how interfaces are often used in Java programming when dealing with 'events' that involve two or more instances of different types. Past experience has revealed that students often find this example a little tricky to understand. Give a good effort to figure it. If you decide to continue on with your programming career you will no doubt encounter this use of interfaces. If you find this a little too tricky, no problem - it's not going to be on the AP Exam.

Watch - "Interfaces Comparable How To Write"
This is another key topic for the interface section of the AP course.
You have used the compareTo method when comparing Strings. Did you know that the compareTo method is part of the Comparable Interface?
This video will walk you through the comparable interface and how to implement the interface for any class that you create or borrow.
Definitely AP Examable.

Watch - "Interfaces Comparable Benefits"
Now that you can make just about any class implement the Comparable interface you should learn why you would want to. In this video we'll look at a few examples of why programmers might want to make their classes implement the Comparable interface.

Review/Practice Questions - "InterfacesWorksheet"
Complete the questions for the previous two videos about the Comparable interface.