JAVA Object Oriented Programming (OOP)

Object Oriented Programming (OOP)


What is OOP?

OOP stands for Object-Oriented Programming.

What is an Object?
Object means a real-world example (entity) .
examples
car, table, chair, computer, watch.
 An object has a unique identity, Properties (state), and behaviors.

Object=Properties (state)+ Behaviors




Java is an object-oriented programming language.
What is a Class?

In Java, a class is a blueprint (Template) for creating Object, and it can contain method and variable.
standards
class Java {                      
string str;
public void () {

}
}

Class name standards: -

Class names in Java are typically written in Pascal Case, which means the first letter of each word in the class name is capitalized, and there are no spaces or underscores between words.

class Java {                      
string str;
public void test(){
}
}

example☝: - "Java " in pervious code.

or 

and other identifiers in Java are typically written in camelCase, which means the first letter of the first word is in lowercase, and the first letter of each subsequent word is capitalized. 

public class nameAli{

string str;

public void test(){
}
}

example☝: - "nameAli"

What is a Variable?

In Java, a variable is a container that holds a value during the execution of a program. Every variable in Java is assigned a data type that designates the type and quantity of value it can hold.

Variable standards: -

Simple letters should be used in variable naming. Names with 2 words are usually separated by underscores to improve readability.
type variable_Name = value;

 What is a Method?

Java methods are blocks of code that perform a specific task and can be called by other parts of the program.

 Methods can be used to keep the things (behaviors) that the object can do inside the class, which is the blueprint for creating objects.

Why use methods? To reuse code: define the code once, and use it many times.



Method standards: -

In Java, when defining a method, you are required to include parentheses ( ) after its name, and these parentheses are used to enclose the method's parameter list. This is a fundamental part of Java's method syntax.

public class Main {

 static void myMethod() {

  }

}

Java has a set of keywords that are reserved words that cannot be used as variables, methods, classes, or any other identifiers.


Object Generating

we can create more objects from the class and change the values of those objects to do the work we need.























Comments