From the course: Nail Your Java Interview

Unlock the full course today

Join today to access over 22,400 courses taught by industry experts or purchase this course individually.

What are classes, instances, and constructors?

What are classes, instances, and constructors? - Java Tutorial

From the course: Nail Your Java Interview

Start my 1-month free trial

What are classes, instances, and constructors?

- [Instructor] Almost anything in real life can be represented in code. Think of the objects around you: a pencil, a chair, a lamp, a computer. On the most fundamental level, the way we represent these objects and how we use them in code is defined in classes. These classes are really blueprints, blueprints for the objects we want to create in code. For example, let's say we wanted to represent a dog in code. We define a given object in Java using attributes and behaviors. Some of the different attributes that define a dog are its breed, its age, and its color. In defining a dog's behavior, something a dog does is bark, so we can define a barking behavior. To represent a dog in code, we would have a Dog class with a String attribute called breed, an int attribute called age, and a String attribute called color. These attributes could also be called fields. We could say the Dog class has a breed field, an age…

Contents