0% found this document useful (0 votes)
3 views1 page

Java Basics Notes

Java is a high-level, object-oriented programming language known for its platform independence and ease of learning. Key features include automatic memory management and robust security, making it suitable for various applications. The document covers Java program structure, data types, control statements, loops, methods, object-oriented principles, input/output, and exception handling.

Uploaded by

sachinspatel43
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)
3 views1 page

Java Basics Notes

Java is a high-level, object-oriented programming language known for its platform independence and ease of learning. Key features include automatic memory management and robust security, making it suitable for various applications. The document covers Java program structure, data types, control statements, loops, methods, object-oriented principles, input/output, and exception handling.

Uploaded by

sachinspatel43
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/ 1

Java Basics Notes 1.

Introduction to Java Java is a high-level, object-oriented, and


platform-independent programming language developed by Sun Microsystems (now owned by
Oracle). It is widely used for web, desktop, and mobile applications. Key Features: Simple and
easy to learn Object-Oriented Programming (OOP) Platform independent (Write Once, Run
Anywhere) Robust and secure Automatic memory management (Garbage Collection) 2. Java
Program Structure A simple Java program looks like this: class HelloWorld { public static void
main(String[] args) { System.out.println("Hello, World!"); } } Explanation: class: Defines a class
named HelloWorld. main: Starting point of every Java program. System.out.println: Prints text to
the console. 3. Java Data Types Primitive Types: byte, short, int, long, float, double, char, boolean
Non-Primitive Types: String, Arrays, Classes, Objects Example: int age = 20; double salary =
45000.50; char grade = 'A'; boolean isPass = true; 4. Variables and Operators Variables store data
values. Operators perform operations on variables. int a = 10, b = 5; System.out.println(a + b); //
Arithmetic operator Types of Operators: Arithmetic: +, -, *, /, % Relational: ==, !=, >, <, >=, <=
Logical: &&, ||, ! Assignment: =, +=, -=, *=, /= 5. Control Statements Used for decision making. if
(age >= 18) { System.out.println("Adult"); } else { System.out.println("Minor"); } 6. Loops Used to
repeat code. for (int i = 1; i <= 5; i++) { System.out.println(i); } 7. Arrays Arrays store multiple values
of the same type. int[] numbers = {10, 20, 30, 40}; System.out.println(numbers[2]); // Output: 30 8.
Methods A method is a block of code that performs a specific task. void greet() {
System.out.println("Welcome to Java!"); } 9. Object-Oriented Programming (OOP) Java is based on
four OOP principles: Encapsulation: Wrapping data and code together. Inheritance: Reusing
code from another class. Polymorphism: Same function behaving differently. Abstraction: Hiding
details and showing essential features. Example: class Animal { void sound() {
System.out.println("Animal sound"); } } class Dog extends Animal { void sound() {
System.out.println("Bark"); } } 10. Input and Output import java.util.Scanner; class InputExample {
public static void main(String[] args) { Scanner sc = new Scanner(System.in);
System.out.print("Enter name: "); String name = sc.nextLine(); System.out.println("Hello, " + name);
} } 11. Exception Handling Used to handle runtime errors. try { int x = 10 / 0; } catch (Exception e) {
System.out.println("Error: " + e.getMessage()); } 12. Summary Java is a powerful and versatile
programming language that forms the foundation for many modern technologies like Android apps,
enterprise software, and web servers. End of Java Basics Notes

You might also like