[Go to site: main page, start]

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

Java Guide

Java is a high-level, object-oriented programming language that runs on the Java Virtual Machine, making it platform-independent and widely used in enterprise applications. It is built around four OOP principles: encapsulation, inheritance, polymorphism, and abstraction, and includes features like control flow, collections, and exception handling. Key tips for Java programming include its static typing, the necessity of a main() method, and the use of tools like Maven or Gradle for dependency management.

Uploaded by

anumitachoubey8
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)
2 views3 pages

Java Guide

Java is a high-level, object-oriented programming language that runs on the Java Virtual Machine, making it platform-independent and widely used in enterprise applications. It is built around four OOP principles: encapsulation, inheritance, polymorphism, and abstraction, and includes features like control flow, collections, and exception handling. Key tips for Java programming include its static typing, the necessity of a main() method, and the use of tools like Maven or Gradle for dependency management.

Uploaded by

anumitachoubey8
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

Java

Write Once, Run Anywhere – Enterprise-Grade OOP

What is Java?
Java is a high-level, class-based, object-oriented programming language designed to have as few
implementation dependencies as possible. It runs on the Java Virtual Machine (JVM), making it
platform-independent. Java is widely used in enterprise applications, Android development, and
backend systems.

Hello World
public class HelloWorld {
public static void main(String[] args) {
[Link]("Hello, World!");
}
}

Data Types & Variables


int age = 25;
double price = 9.99;
boolean isActive = true;
char grade = 'A';
String name = "Alice";

Object-Oriented Programming (OOP)


Java is built around four OOP pillars:

• Encapsulation – Bundling data and methods in a class


• Inheritance – A class can extend another class
• Polymorphism – Same method, different behavior
• Abstraction – Hiding complexity behind interfaces
public class Animal {
String name;
void speak() { [Link]("..."); }
}

public class Dog extends Animal {


void speak() { [Link]("Woof!"); }
}

Control Flow
// If-else
if (age >= 18) {
[Link]("Adult");
} else {
[Link]("Minor");
}

// For loop
for (int i = 0; i < 5; i++) {
[Link](i);
}

// While loop
while (count > 0) { count--; }

Collections
import [Link].*;

List<String> list = new ArrayList<>();


[Link]("Java");
[Link](0);

Map<String, Integer> map = new HashMap<>();


[Link]("score", 100);
[Link]("score");

Exception Handling
try {
int result = 10 / 0;
} catch (ArithmeticException e) {
[Link]("Error: " + [Link]());
} finally {
[Link]("Always runs");
}

Key Tips
• Java is statically typed – declare variable types explicitly
• Every Java program needs a main() method as entry point
• Use Maven or Gradle for dependency management
• Java 8+ features: Streams, Lambdas, Optional are essential
• The JDK includes the compiler (javac) and runtime (java)

You might also like