How to Start this Concept?
In the early days of Java, all code was written in a single java
file. This can contain more than 100000 lines of code. For example, imagine
that you want to create a learning management system so that all the fields are
typed one after the other in the same java file. When you read this you think
that you can easily create a program like this.
But it
was very difficult for a later computer program developer to develop programs
like this. In the development of the program, if the file consists of about
100000 lines, the developer has to read it again, then a lot of time and effort
is spent, so the developers have to pay a lot of money. For this reason,
computer developers introduce a new concept to the world, this is called
object-oriented programming.
What happens in object-oriented programming?
What happens here is not to create a big system in one Java file, but according to the ease of identifying it, separate it into main objects and create each Java file for each object, connect each Java file to one main Java file, and create the main system. for example, if you have to create a system for a bank, you have the ability to create the required bank management system by separating the gold goods mortgage section, check deposits, balance transactions, and loans creating them as objects and adding them to the main system.
This contains four main concepts. that is,
- Objects
- Classes
- Methods
- Variables
Object is,
An object is anything we can describe as an object in
creating a computer program, but it must contain properties and behavior. For
example, suppose you create a system that enters student scores and manipulates
student scores. Students can be taken as an object of that system. That is,
Thus, the student has the marks for the relevant subjects,
it is the student's properties, so calculating the total marks and calculating
the average marks can be seen as functions related to the student object.
Programs related to this type have the ability to identify objects.
A class is,
According to the example I mentioned above, an object is
created there as students. Sometimes, if we must enter the data of 50 students
in the system, we have to create 50 objects, then to make it easier to enter
data for those objects, we can create one template for all objects because we
have to enter the same type of data for all objects. We call that template a
class.
For example, we give a form to the students to give all the
data to all 50 children. We can call that one a class.
variables are,
According to the example I mentioned above, we can describe the properties included in the object called the student as the variables of that object. According to the picture above, the email and address mentioned in the picture are variables of the class human.
Also the method is,
The behavior of the object we select can be described as the method of that object, the behavior of verify and send mail in the above picture is the method of that object. Also, in the above example, calculating the total score and calculating the equal score is also the method of that object.
Java Language Standards
- Words include in Java language which is Start with a capital letter it is called the “CLASS” name.
- Example: System, String, Subject
- when we use some words in java language which start with a simple letter it’s called “Variables”.
- Example: out, mark, number
- As well as we use some words which is start with a simple letter and end with parentheses, which can be called as “Methods”.
- Example: test(), check(), run()
Let's be clear with JAVA print statements.
System.out.print(“Hello word”)
- System is Class
- Out is Variable
- Print is Method
- ‘’hello word’’ is a parameter of the print method
It can be defined as Display hello world using the ‘’print’’ method in the ‘’out’’ variable of the ‘’system’’ class.
“=” vs “==”
‘’=’’ is used to assign some values to variables and it can be changed at any time.
But,
“==” this isn’t used to assign values to variables, it is used to equalize some values to variables, and it can’t be changed after equalization at one time.
Example:
String a = ’abcd’;
a = ’efgh’;
String b == ’ijkl’;
b == ‘mnop’; (this is wrong and can generate an error)
print(a,b)
Answer = efgh ijkl
No comments:
Post a Comment