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

Java Unit1 Notes

The document outlines the salient features of Java, highlighting its simplicity, object-oriented nature, platform independence, and security. It covers key concepts in object-oriented programming, including classes, objects, encapsulation, inheritance, polymorphism, and abstraction. Additionally, it discusses basic constructs, typecasting, arrays, strings, and class fundamentals, emphasizing Java's memory management and garbage collection features.

Uploaded by

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

Java Unit1 Notes

The document outlines the salient features of Java, highlighting its simplicity, object-oriented nature, platform independence, and security. It covers key concepts in object-oriented programming, including classes, objects, encapsulation, inheritance, polymorphism, and abstraction. Additionally, it discusses basic constructs, typecasting, arrays, strings, and class fundamentals, emphasizing Java's memory management and garbage collection features.

Uploaded by

krishnalamani364
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Java Unit 1 Notes

Salient Features of Java


- Simple: Easy to learn, similar to C++, but without complex features like pointers.
- Object-Oriented: Everything in Java is treated as an object.
- Platform Independent: Compiled into bytecode which runs on JVM.
- Secure: Provides runtime security through bytecode verification.
- Robust: Strong memory management and exception handling.
- Multithreaded: Supports multithreaded programming.
- Portable: Write once, run anywhere (with JVM).
- Distributed: Supports distributed computing.
- High Performance: JIT compiler improves runtime performance.

Object-Oriented Programming Approach


- Class: Blueprint for creating objects.
- Object: Instance of a class.
- Encapsulation: Wrapping data and code together.
- Inheritance: One class can inherit from another.
- Polymorphism: Same interface, different implementations.
- Abstraction: Hiding internal details.

Byte Code and JVM


- Bytecode: Intermediate code compiled by Java compiler.
- JVM: Converts bytecode to machine code and enables platform independence.

Basic Constructs
- Variables: Store data. e.g., int x = 10;
- Data Types: Primitive (int, char, boolean), Reference (arrays, objects).
- Operators: Arithmetic, Logical, Relational, etc.
- Control Statements: if, switch, loops (for, while), break, continue.
- Input: Scanner sc = new Scanner([Link]);
Typecasting
- Widening (Implicit): int to double.
- Narrowing (Explicit): double to int, with data loss possible.

Arrays
- One-Dimensional: int[] arr = new int[5];
- Multi-Dimensional: int[][] matrix = new int[3][3];

String and StringBuffer


- String: Immutable. e.g., String s = "Hello";
- StringBuffer: Mutable. e.g., [Link](" World");

Classes
- Class Fundamentals: class Car { int speed; void drive() {} }
- Declaring Objects: Car c = new Car();
- Object Reference Variables: Hold address of the object.
- Constructors: Initialize object. Can be default or parameterized.
- this Keyword: Refers to current object instance.
- Garbage Collection: Automatic memory management.
- finalize(): Called before object is destroyed by GC.

You might also like