Java Fundamentals  «Prev  Next»
Lesson 1

Working with Java Objects and Classes

In this module, you will develop your OOP skills by creating objects from classes. You will learn how to overload methods, how to create instances of classes, and how to override methods in derived classes.
You will practice your OOP skills by creating simple object-oriented Java applications.

Module Learning Objectives

After completing the module, you will have the skills and knowledge necessary to:
  1. Create objects from classes
  2. Create overloaded methods
  3. Build a hierarchy of classes using inheritance
  4. Override methods in derived classes
Java is an Object-Oriented programming language. As an issue that has the Object Oriented peculiarity, Java underpins the accompanying essential ideas:
  1. Inheritance
  2. Polymorphism
  3. Abstraction
  4. Encapsulation
  5. Objects
  6. Message Parsing
  7. Classes
  8. Method
  9. Instance

Classes and Objects

In this module, we will investigate the concepts of Classes and Objects. A class can be described as an blueprint that declares and defines the attributes and methods that its objects will implement and use. Objects are simple real world entities that possess a state and its characteritic behaviour. For example, if you consider a real world entity, a labrador dog, then this dog is an object. However, it belong to the class of dogs. Therefore, the associated class is Dog.

Objects in Java

Let us now look profoundly into what are objects. In the event that we consider this present reality, we can discover numerous entities around us, Cars, Humans, Dogs and several other. In fact, any real world entity can be modelled as an object. The one common thing between all these entities is the fact that they contain states and behaviours. On the off chance that we consider a dog, then its state is - breed, name and color. However, its behaviour includes eating habits and other characteristics like running and barking.

Classes in Java

A class is a blue print from which individual objects are made. A specimen of a class is given underneath:
open class Dogs {
 String breed;
 String shade;
 int age;
 void eating (){ }
 void barking (){ }
}