-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCh01_01_Main.java
More file actions
34 lines (27 loc) · 1.34 KB
/
Ch01_01_Main.java
File metadata and controls
34 lines (27 loc) · 1.34 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
28
29
30
31
32
33
34
/* Author - Vadanta Kumar Chauhaan
Year : 2025 */
public class Ch01_01_Main { //Class consists of different functions to be executed
public static void main(String[] args) { //static void file() is the function to be executed
System.out.println("Hello World");
byte cod3; //variable - starts with data type followed by name
//Program to add three numbers
System.out.print("The sum of three numbers are:");
int num1 = 13;
int num2 = 3;
int num3 = 12;
int sum = num1 + num3 + num2;
System.out.print(sum);
}
}
//static - adds something to the current class.
//Naming Conventions 1. Class- PascalConvention 2. function - camelCaseConvention
//Anatomy of a Java Code
// 1. Documentation Section - Suggested comments
// 2. Package Statement - Tells a class belongs to which package (Optional)
// 3. Import Statements - To take Input from users (optional)
// 4. Class Definitions - Naming of different classes (optional)
// 5. Main Method Class /n { /n Main Method Definition /n } (Essential - starting point of a Java Code)
//Data Types in Java 1. Primitive 2. Non-Primitive
//Primitive - int(4 bytes) , byte (-128 to 127) , char (2 bytes and no negative values) , float(4 bytes) , short (2bytes) , bool etc.
// 1byte = 8bits
// all value ranges from 2^bits-1 to (2^bits - 1) - 1.