JAVA Features
Feature Description Example Code
Java follows OOP java class Animal { void sound() {
concepts like [Link]("Animal makes a sound"); } }
Object- Encapsulation, class Dog extends Animal { void sound() {
Oriented Inheritance, [Link]("Dog barks"); } } public class
Polymorphism, and Main { public static void main(String[] args) {
Abstraction. Animal myDog = new Dog(); [Link](); } }
Java programs compile to Write a Java program on Windows, compile it with
Platform
bytecode, which can run javac [Link], and run it on Linux or Mac
Independent
on any OS with JVM. using java MyProgram.
Java removes complex
Java does not require pointer arithmetic like C/C++.
Simple & features like explicit
Example: java int num = 10;
Easy to Learn pointers and manual
[Link](num); // No need for pointers!
memory management.
Java prevents memory manipulation errors: java
Java does not use explicit
public class SecurityExample { public static void
pointers, has bytecode
Secure main(String[] args) { String password = "secure";
verification, and allows
[Link]([Link](".", "*")); }
security managers.
}
Java bytecode runs on any Write a program on Windows, compile it with javac,
Portable
machine with a JVM. and run it on Linux/Mac without modification.
java class MyThread extends Thread { public void
Java allows execution of
run() { [Link]("Thread is running"); } }
Multithreading multiple threads in
public class Main { public static void main(String[]
parallel.
args) { MyThread t = new MyThread(); [Link](); } }
Java uses the JIT compiler
High and optimized garbage Java JIT compiles bytecode into native machine
Performance collection for better code for speed.
performance.
Java handles errors using java public class ExceptionExample { public static
Robust & exception handling and void main(String[] args) { try { int a = 10 / 0; }
Reliable automatic garbage catch (ArithmeticException e) {
collection. [Link]("Cannot divide by zero!"); } } }
Java supports RMI, Web Java RMI Example: java import [Link].*; public
Distributed
Services, and CORBA for interface Hello extends Remote { String sayHello()
Computing
distributed applications. throws RemoteException; }
Java loads classes
Dynamic class loading: java Class<?> clazz =
Dynamic and dynamically at runtime
[Link]("[Link]");
Extensible and integrates external
[Link]([Link]());
libraries.
Feature Description Example Code
java public class GarbageExample { protected void
Automatic Java automatically finalize() { [Link]("Garbage
Garbage removes unused objects collected!"); } public static void main(String[] args)
Collection using garbage collection. { GarbageExample obj = new GarbageExample();
obj = null; [Link](); } }
Using Java Collections: java import [Link].*;
Java provides a vast API
public class CollectionExample { public static void
Rich Standard for data structures,
main(String[] args) { List<String> list = new
Library networking, file handling,
ArrayList<>(); [Link]("Java"); [Link]("Python");
etc.
[Link](list); } }
Java is used for enterprise
applications, from small Java is used in Android development, Spring Boot,
Scalability
apps to large-scale Hadoop, etc.
systems.
java import [Link].*; public class StreamExample
{ public static void main(String[] args) {
Java supports Lambda
Functional List<String> names = [Link]("Alice", "Bob",
expressions and Streams
Programming "Charlie"); [Link]().filter(name ->
API.
[Link]("A")).forEach([Link]::println);
}}