forked from fineanmol/Hacktoberfest2025
-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathJavaSyntax.txt
More file actions
27 lines (19 loc) · 1.17 KB
/
JavaSyntax.txt
File metadata and controls
27 lines (19 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
Java program is a collection of objects, and these objects communicate through method calls to each other to work together. Here is a brief discussion on the Classes and Objects, Method, Instance variables, syntax, and semantics of Java.
Basic terminologies in Java
1. Class: The class is a blueprint (plan) of the instance of a class (object). It can be defined as a template that describes the data and behavior associated with its instance.
Example: Blueprint of the house is class.
2. Object: The object is an instance of a class. It is an entity that has behavior and state.
Example: A car is an object whose states are: brand, color, and number plate.
Behavior: Running on the road.
3. Method: The behavior of an object is the method.
Example: The fuel indicator indicates the amount of fuel left in the car.
4. Instance variables: Every object has its own unique set of instance variables. The state of an object is generally created by the values that are assigned to these instance variables.
Example: Steps to compile and run a java program in a console
javac GFG.java
java GFG
public class GFG {
public static void main(String[] args)
{
System.out.println("GFG!");
}
}