Loading lesson path
Java
Java Classes focused on Java OOP and related concepts.
OOP stands for Object-Oriented Programming .
Java is an object-oriented programming language.
In Java, variables declared inside a class are called " attributes ".
You learned from the Java Methods chapter that methods are declared within a class, and that they are used to perform certain actions:
A constructor in Java is a special method that is used to initialize objects.
The this keyword in Java refers to the current object in a method or constructor.
By now, you are quite familiar with the public keyword that appears in almost all of our examples:
Non-access modifiers do not control visibility (like public or private ), but instead add other features to classes, methods, and attributes.
- declare class variables/attributes as private - provide public get and set methods to access and update the value of a private variable
A package in Java is used to group related classes. Think of it as a folder in a file directory . We use packages to avoid name conflicts, and to write a better maintainable code. Packages are divide…
In Java, it is possible to inherit attributes and methods from one class to another. We group the "inheritance concept" into two categories:
Polymorphism means "many forms", and it occurs when we have many classes that are related to each other by inheritance.
In Java, the super keyword is used to refer to the parent class of a subclass.
In Java, it is also possible to nest classes (a class within a class). The purpose of nested classes is to group classes that belong together, which makes your code more readable and maintainable.
Data abstraction is the process of hiding certain details and showing only essential information to the user. Abstraction can be achieved with either abstract classes or interfaces (which you will le…
Another way to achieve abstraction in Java, is with interfaces.
An anonymous class is a class without a name. It is created and used at the same time.
An enum is a special "class" that represents a group of constants (unchangeable variables, like final variables).
An enum can also have a constructor just like a class.
The Scanner class is used to get user input, and it is found in the java.util package.
Java does not have a built-in Date class, but we can import the java.time package to work with the date and time API. The package includes many date and time classes. For example: