🌟 Core Java Basics – Introduction
Core Java Basics are essential for anyone starting Java programming. In this guide, you will learn about variables, loops, arrays, constructors, class members, and how Java code is compiled and executed by the JVM.
🔹 Core Java Basics – Data Types
- Primitive Data Types:
- byte → 8-bit (-128 to 127)
- short → 16-bit
- int → 32-bit whole numbers
- long → 64-bit large whole numbers
- float → 32-bit decimal
- double → 64-bit decimal
- char → single character
- boolean → true/false
- Non-Primitive Data Types:
- String → text
- Arrays
- Classes & Objects
🔹 Core Java Basics – Variables
- A variable = a container for storing data.
- Must declare with data type + name.
|
1 2 3 4 |
int age = 25; String name = "John"; boolean isActive = true; |
🔹 Core Java Basics – Loops
- for loop → repeat fixed times
- while loop → repeat until condition is false
- do-while loop → runs at least once, then checks condition
🔹 Core Java Basics – Arrays
- Store multiple values of the same type.
- Index starts at 0.
- Access element → numbers[0]
|
1 2 |
int[] numbers = {1, 2, 3, 4}; |
🔹 Core Java Basics – Constructors
- Special method to initialize objects.
- Same name as class, no return type.
|
1 2 3 4 5 6 |
class Student { Student() { System.out.println("Constructor called"); } } |
🔹 Core Java Basics – Class Members
- Fields / Variables → store data
- Methods → define behavior of class
- Static members → belong to class
- Instance members → unique to each object
🔹 Core Java Basics – Coding Conventions
- Class names → UpperCase start (e.g., StudentDetails)
- Variable & method names → camelCase (e.g., rollNumber, getName)
- Constants → ALL_CAPS (e.g., MAX_VALUE)
- Use indentation & comments → for readability
🔹 Core Java Basics – Compilation & JVM Execution
- Java source code → .java file
- Compilation → javac FileName.java → generates bytecode (.class file)
- Bytecode → platform-independent instructions for JVM
- JVM Execution → java FileName → JVM interprets bytecode into machine code
- Flow:
- Write code → FileName.java
- Compile → FileName.class
- Run → JVM executes FileName.class on your system
Very Good info! explained each steps in understandable way.
This blog is the general information for the feature. You got a good work for these blog.We have a developing our creative content of this mind.
Thank you for this blog. This for very interesting and useful.
Very Good Info and easy to understand too.
please provide more quizzes in core Java and selenium including Testng.
Thank you for giving this blog which is very useful for everyone.