[go: up one dir, main page]

0% found this document useful (0 votes)
2 views3 pages

Java_Basics_Quick_Notes

The document provides an overview of Java programming, covering its basics, including JVM, JRE, and JDK. It explains variables, data types, operators, control flow statements, OOP concepts, string and array handling, exception handling, access modifiers, and the use of static and final keywords. Additionally, it discusses packages and imports for organizing code in Java.

Uploaded by

Jayanth Cl
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views3 pages

Java_Basics_Quick_Notes

The document provides an overview of Java programming, covering its basics, including JVM, JRE, and JDK. It explains variables, data types, operators, control flow statements, OOP concepts, string and array handling, exception handling, access modifiers, and the use of static and final keywords. Additionally, it discusses packages and imports for organizing code in Java.

Uploaded by

Jayanth Cl
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

1.

Java Basics

Java:
Java is a platform-independent, object-oriented programming language. It runs on the Java Virtual
Machine (JVM).
JVM (Java Virtual Machine):
JVM runs Java bytecode on any device. It handles memory and platform independence.
JRE (Java Runtime Environment):
JRE provides libraries and JVM to run Java programs. It is used for executing Java applications.
JDK (Java Development Kit):
JDK includes JRE plus tools like compiler and debugger. Required to write and run Java code.

2. Variables and Data Types

Variable:
A variable stores data in memory. Types: local, instance, static.
Data Types:
Java has primitive types (int, float, boolean, etc.) and reference types (String, arrays). They define
the nature of data a variable holds.
Constants:
Constants are declared using final. Their values cannot be changed once assigned.

3. Operators

Arithmetic Operators:
Used for mathematical operations like +, -, *, /. Work with numeric data types.
Relational Operators:
Compare values (==, !=, >, <, etc.). Return boolean results.
Logical Operators:
Perform logical operations (&&, ||, !). Used in decision-making conditions.

4. Control Flow Statements

If-Else:
Used to execute code based on conditions. if (condition) { } else { }
Switch:
Used for multi-way branching based on a variable's value. Better than multiple if-else statements.
Loops (for, while, do-while):
Used to repeat code blocks. Loop continues until a condition is false.
Break and Continue:
break exits a loop early, continue skips to the next iteration. Used to control loop flow.

5. OOPs Concepts

Class:
A blueprint for creating objects. Contains fields and methods.
Object:
An instance of a class. Has state and behavior.
Constructor:
Special method to initialize objects. Called when an object is created.
Inheritance:
One class inherits features of another using extends. Promotes code reusability.
Polymorphism:
Same method behaves differently (overloading & overriding). Achieved at compile-time or runtime.
Encapsulation:
Hides data using private fields and public methods. Protects object integrity.
Abstraction:
Hides complex implementation and shows only essential features. Done using abstract classes or
interfaces.
Interface:
A contract of abstract methods. Implemented by classes using implements.

6. String and Arrays

String:
A sequence of characters, immutable in Java. Handled using the String class.
StringBuffer / StringBuilder:
Mutable alternatives to String. Used when frequent modifications are needed.
Arrays:
Collection of fixed-size elements of the same type. Indexed starting from 0.

7. Exception Handling

Try-Catch:
Catches and handles runtime errors. Prevents program from crashing.
Finally:
Always executes after try-catch. Used for cleanup code.
Throw/Throws:
Used to manually throw or declare exceptions. Helps manage checked exceptions.

8. Access Modifiers

Public:
Accessible everywhere. Used for shared components.
Private:
Accessible only within the class. Used to protect data.
Protected:
Accessible within package and subclasses. Supports inheritance.
Default (no modifier):
Accessible only within the package. Used for package-level access.

9. Static and Final Keywords

Static:
Belongs to the class, not objects. Shared across all instances.
Final:
Used to declare constants or prevent modification. Final class can't be extended; final method can't
be overridden.

10. Packages and Imports

Package:
Groups related classes and interfaces. Helps in organizing code.
Import:
Used to access classes from other packages. Syntax: import package.ClassName;

You might also like