
Object-oriented programming languages require you to think in terms of objects and classes. We formally introduce these concepts, as well as encapsulation, abstraction, inheritance and other basic tenets of OO programming. Next come instantiation, member variables and member functions (static and non-static), start with access modifiers (public, private, protected) and finish with constructors and finalizers.
Static member variables and static member functions are class-specific, not object-specific.
Member variables and functions can be marked public, private or protected - these keywords are called access modifiers, and they govern the access that derived class objects have to their corresponding base class objects.
A simple coding drill that demonstrates all that we've covered so far: defining classes,instantiation(creating objects), different member variables and different member functions, getters, setters, constructors and finalizers.
We continue our simple coding drill that demonstrates all that we've covered so far: defining classes,instantiation(creating objects), different member variables and different member functions, getters, setters, constructors and finalizers. In this bit, we focus on instantiating objects, and on static member data.
What does it really mean for a class to derive from another class? We examine the idea of inheritance using Shapes.
We continue with our exploration of inheritance and explore how derived class objects have a full version of the base class object within them. This is illustrated using a class hierarchy involving planes and fighter planes.
Runtime polymorphism is an important OO concept. If an object of type Rectangle holds a reference to derived class Square, will our shape behave like a Rectangle or a Square?
We explore the Object base class, which all Java reference types derive from.
We introduce Interfaces: a special type of classes that have only function signatures but no function implementations.
Abstract base classes and abstract functions are covered in this class. We also compare when it makes sense to use interfaces, and when abstract base classes are a better choice.
Upcasting, downcasting and the instanceof operator. Upcasting is OK but be careful with downcasting!
Interface default methods are a new feature in Java, that allow us to go back and retro-fit new methods into old interfaces. Interface default methods involve adding implementations to interfaces, which might seem like cheating, but its all in a great cause: this prevents an explosion of the class hierarchy and maintains backward compatibility in code.
We've talked a lot about interfaces, now let's walk the talk with a nice little drill.
Strings never change. Unlike almost everything else in life, they are immutable. Let's see how.
When are two objects 'equal'? How are the == operator and .equals() different from each other?
Generics are a language feature that help Java maintain its tight rules on Type Safety, while also facilitating code re-use.
Decades ago, when Java first appeared, its incredibly handy collections were among its biggest attractions over C++; much has changed, but Java collections are still incredible. Lists, maps, sets, and standard ways to iterate over them.
Java has a clever way to sort collections: using Comparator objects. (Aside: This clever technique combines the Strategy and the Command Design Pattern). We see how Comparators and Collections work together: nested classes (the classes inside classes) and types of nested classes (static and non-static classes which are also called anonymous inner or local classes).
We wrap up our exploration of inner classes with a look at Anonymous and local classes. Anonymous classes are used heavily in UI, while local classes are very infrequently used.
We will be making a useful Java application in this drill using concept of files, classes, nested classes and comparator. The Java application will download daily stock data from a stock exchange website and output an excel file of top movers and heavily traded stocks.
We will be making a useful Java application in this drill using a java library (JAR) called POI created by open-source powerhouse called Apache. The JAR POI has a set of classes to work with excel. The Java application will download daily stock data from a stock exchange website and output an excel file of top movers and heavily traded stocks.
We will talk about packages and jars in this lecture. We will talk about what they mean, how they are useful and how jar files are smarter than zip files (Hint: self-awareness is the start of smartness. Another hint: Metadata)
A little drill where we see packages and jars in action
This is a quick and handy course with exactly what you need to know (nothing more, nothing less!) about Object-Oriented programming in Java
Let’s parse that.
What's covered: