In this course, we'll learn the object-oriented concept in Java.
Learning Objectives
- Object-Oriented programming concept
- Object & Class
- Access Modifiers
- Naming Conventions
- Constructors
- Packages
- Static Keyword
- Nested and Inner Classes
Intended Audience
- Anyone looking to get Oracle Java Certification
- Those who want to learn the Java Programming language from scratch
- Java developers who want to increase their knowledge
- Beginners with no previous coding experience in Java programming
- Those who want to learn tips and tricks in Oracle Certified Associate – Java SE 8 Programmer certification exams
Prerequisites
- No prior knowledge is required about the Java programming language
- Basic computer knowledge
Hi there. Object-Oriented Programming, OOP, is a method of designing and implementing software. The primary purpose of Object-Oriented Programming is to increase the flexibility and maintain ability of programs. It simplifies software development and maintenance by providing some concepts. These concepts are object, class, inheritance, polymorphism, abstraction, and encapsulation. We'll cover these subjects in detail in this course. Let's start with the Object-Oriented concept. Object in class. A class is a group of similar entities. An object can be defined as an instance of a class. Objects are often used to model real world objects you find in everyday life. A Java object is a self contained component, which consists of methods and properties. An object contains an address and takes up some space in memory, but a class doesn't consume any memory space.
The object has three characteristics. It has state, behavior and identity. Now, let's try to understand these characteristics in the next slide. Characteristics of object. The object has three characteristics. It has state, behavior, and identity. The state represents the data of an object, behavior represents the action of an object such as start, stop, etc. Identity is used internally by the Java Virtual Machine, to identify each object uniquely. The value of the ID is not visible to the external user. Let's talk about a car. Its name is Ferrari. Its color is red, and the model is 2015. These are its state.
This car starts and stops. So, starting and stopping are its behavior. Object in class example. Let's take an example with object in class. For instance, we defined a Car Class and the properties of an object car, maybe model, color, and year. An object also executes some actions. A car is capable of performing the following actions; start, stop, and accelerate. Now, as you can see on the slide for different values of properties: model, color, year; in Class Car, we'll get different car objects. In our example, we have one class. Also, we have three objects. Class declaration. Every Java application must have at least one class definition. A class is declared by the use of the class keyword. The class body is enclosed between curly braces.
The data of variables are defined in the class, and these variables are called instance variables. The action code is written in the method. All code blocks are in the class body. Variables and methods are defined in the class, and these are members of the class. Creating an object. An object is created from a class. In Java, the new keyword is used to create new objects. As you see in the slide, we created the myCar object from the Car class by using the new keyword. Car myCar = new Car();. Here, the myCar object is the reference which holds the memory address of the car object, and you can create more than one object from a class. Okay, I think the concepts of object in class are better formed in your mind. Let's take a short break here. See you in the next lesson.
OAK Academy is made up of tech experts who have been in the sector for years and years and are deeply rooted in the tech world. They specialize in critical areas like cybersecurity, coding, IT, game development, app monetization, and mobile development.