[Go to site: main page, start]

0% found this document useful (0 votes)
6 views15 pages

Java Coding Notes

Java is a high-level, object-oriented programming language known for its platform independence and wide usage in various applications. Key features include simplicity, security, and support for multithreading, while the Java ecosystem consists of JVM, JRE, and JDK. The document covers essential concepts such as data types, variables, operators, control statements, OOP principles, exception handling, collections, and multithreading.

Uploaded by

jihoney579
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)
6 views15 pages

Java Coding Notes

Java is a high-level, object-oriented programming language known for its platform independence and wide usage in various applications. Key features include simplicity, security, and support for multithreading, while the Java ecosystem consists of JVM, JRE, and JDK. The document covers essential concepts such as data types, variables, operators, control statements, OOP principles, exception handling, collections, and multithreading.

Uploaded by

jihoney579
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

Page 1: Introduction to Java

Java is a high-level, object-oriented programming language developed by Sun Microsystems. It is


platform-independent because of JVM (Java Virtual Machine). Java is widely used in web
development, Android apps, enterprise software, and backend systems.
Page 2: Features of Java

Java is Simple, Secure, Platform Independent, Object-Oriented, Robust, Multithreaded, Portable


and High Performance.
Page 3: JVM, JRE and JDK

JVM: Java Virtual Machine executes bytecode. JRE: Java Runtime Environment provides libraries
and JVM. JDK: Java Development Kit provides tools to develop Java programs.
Page 4: Basic Java Program Structure

A Java program must have a class and main method.

public class HelloWorld {


public static void main(String[] args) {
[Link]("Hello, World!");
}
}
Page 5: Data Types in Java

Primitive Types: int, float, double, char, boolean, long, short, byte. Non-Primitive Types: String,
Arrays, Classes, Interfaces.
Page 6: Variables in Java

There are three types of variables: 1. Local Variable 2. Instance Variable 3. Static Variable
Page 7: Operators in Java

Arithmetic: + - * / % Relational: == != > < >= <= Logical: && || !


Page 8: Conditional Statements

Java supports if, if-else, nested if, switch statements.

int num = 10;


if(num > 5){
[Link]("Greater than 5");
}else{
[Link]("Less or equal to 5");
}
Page 9: Loops in Java

Java provides for loop, while loop and do-while loop.

for(int i=1; i<=5; i++){


[Link](i);
}
Page 10: Object-Oriented Programming Concepts

Main OOP concepts in Java: 1. Encapsulation 2. Inheritance 3. Polymorphism 4. Abstraction


Page 11: Classes and Objects

Class is a blueprint of an object. Object is an instance of a class.

class Car {
String color;
void drive(){
[Link]("Car is driving");
}
}
Page 12: Inheritance

Inheritance allows one class to acquire properties of another class.

class Animal {
void sound(){
[Link]("Animal makes sound");
}
}
class Dog extends Animal {
void bark(){
[Link]("Dog barks");
}
}
Page 13: Exception Handling

Java uses try, catch, finally, throw and throws keywords.

try {
int a = 10/0;
} catch(Exception e) {
[Link]("Error: " + e);
}
Page 14: Collections Framework

Java Collection Framework includes List, Set, Map interfaces. Common classes: ArrayList,
HashSet, HashMap.
Page 15: Multithreading in Java

Multithreading allows concurrent execution of two or more threads for maximum CPU utilization.

class MyThread extends Thread {


public void run(){
[Link]("Thread running");
}
}

You might also like