#21 Class And Object Theory in Java
Telusko
Object Oriented Programming in Java
Java is an object oriented programming language. In the real world,
everything is an object, from pens to remotes to humans. Every object has
two things: it knows something and it does something. For example, a pen
has properties like color, height, and brand, and it has behavior like
writing. In programming, we treat everything as an object, and we create
objects with properties and behavior in Java.
Creating Objects in Java
To create an object in Java, we first need to create a class. A class is like a
blueprint for the object, and it defines the properties and behavior of the
object. Once we have a class, we can create an object from it using the
Java Virtual Machine (JVM). The JVM takes the class file, which is compiled
from the source code, and creates an object from it.
Thinking in Objects
When programming in Java, it's important to think in objects. For example,
if we want to add two numbers, we should create an object that can add
numbers. Everything we do in Java should be done with the help of an
object
Telusko
Object Oriented Programming in Java
Java is an object oriented programming language. In the real world,
everything is an object, from pens to remotes to humans. Every object has
two things: it knows something and it does something. For example, a pen
has properties like color, height, and brand, and it has behavior like
writing. In programming, we treat everything as an object, and we create
objects with properties and behavior in Java.
Creating Objects in Java
To create an object in Java, we first need to create a class. A class is like a
blueprint for the object, and it defines the properties and behavior of the
object. Once we have a class, we can create an object from it using the
Java Virtual Machine (JVM). The JVM takes the class file, which is compiled
from the source code, and creates an object from it.
Thinking in Objects
When programming in Java, it's important to think in objects. For example,
if we want to add two numbers, we should create an object that can add
numbers. Everything we do in Java should be done with the help of an
object