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

Java_Basics_Notes

Java is a high-level, object-oriented programming language designed for platform independence, widely used for mobile and web applications. Key features include simplicity, security, robustness, and dynamic capabilities, along with a variety of data types and operators. A simple Java program example demonstrates the structure and syntax of Java code.

Uploaded by

bhanuurathore12
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)
5 views3 pages

Java_Basics_Notes

Java is a high-level, object-oriented programming language designed for platform independence, widely used for mobile and web applications. Key features include simplicity, security, robustness, and dynamic capabilities, along with a variety of data types and operators. A simple Java program example demonstrates the structure and syntax of Java code.

Uploaded by

bhanuurathore12
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

Java Basics Notes

Definition of Java

Java is a high-level, class-based, object-oriented programming language developed by Sun Microsystems in

1995 (now owned by Oracle Corporation). It is designed to have as few implementation dependencies as

possible, which makes it a platform-independent language thanks to the Java Virtual Machine (JVM). Java is

widely used for building mobile applications (especially Android), web-based applications, enterprise-level

solutions, and more. Its philosophy is "Write Once, Run Anywhere" (WORA).

Features of Java

1. Simple: Easy to learn with a syntax similar to C++ but without complex features like pointers.

2. Object-Oriented: Everything in Java is treated as an object which improves code reusability.

3. Platform Independent: Java code is compiled into bytecode which runs on any machine with a JVM.

4. Secure: Java provides runtime security features like bytecode verification and no explicit memory pointers.

5. Robust: Java handles memory management automatically with garbage collection and has strong

exception handling.

6. Multithreaded: Allows simultaneous execution of two or more threads for maximum CPU utilization.

7. High Performance: Uses Just-In-Time (JIT) compiler to improve performance.

8. Distributed: Java can be used to create distributed applications using tools like RMI and EJB.

9. Dynamic: Java can adapt to evolving environments through dynamic linking and loading of classes at

runtime.

Data Types in Java

Primitive Data Types

Data Type Size Default Value Description

byte 1 byte 0 Whole numbers from -128 to 127


Java Basics Notes

short 2 bytes 0 Whole numbers from -32,768 to 32,767

int 4 bytes 0 Most commonly used integer type

long 8 bytes 0L Larger range of integers

float 4 bytes 0.0f Single-precision decimal numbers

double 8 bytes 0.0d Double-precision decimal numbers

char 2 bytes '\u0000' Single Unicode character

boolean 1 bit false Stores true or false

Operators in Java

Java Operators

Operator Type Operators Description

Arithmetic +, -, *, /, % Basic arithmetic operations

Relational ==, !=, >, <, >=, <= Compare two values

Logical &&, ||, ! Logical operations

Assignment =, +=, -=, *=, /=, %= Assign and modify values

Unary +, -, ++, --, ! Single operand operations

Bitwise &, |, ^, ~, <<, >>, >>> Operate at bit level

Ternary ?: Conditional decision making

Expressions in Java

An expression in Java is a construct made up of variables, operators, and method calls that evaluates to a

single value.

Example:

int sum = a + b * 10;


Java Basics Notes

Here, 'a + b * 10' is an expression performing arithmetic computation.

Types of Expressions:

- Arithmetic Expressions: a + b, x * y

- Relational Expressions: a > b, x == y

- Logical Expressions: x > 5 && y < 10

Simple Java Program Example

public class HelloWorld {

public static void main(String[] args) {

// This prints "Hello, World!" to the console

System.out.println("Hello, World!");

Explanation:

- public class HelloWorld: Declares a class named HelloWorld.

- public static void main(String[] args): The main method where the program starts execution.

- System.out.println(): Prints the specified message to the console.

You might also like