0% found this document useful (0 votes)
15 views

Java_CheatSheet

This Java Quick Cheat Sheet covers essential concepts including Java basics, data types, object-oriented programming principles, control statements, arrays and strings, exception handling, file handling, collections framework, and JDBC. It provides concise examples and explanations for each topic. This guide serves as a quick reference for Java programming fundamentals.
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)
15 views

Java_CheatSheet

This Java Quick Cheat Sheet covers essential concepts including Java basics, data types, object-oriented programming principles, control statements, arrays and strings, exception handling, file handling, collections framework, and JDBC. It provides concise examples and explanations for each topic. This guide serves as a quick reference for Java programming fundamentals.
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 Quick Cheat Sheet

1. Java Basics
- Platform-independent, Object-Oriented.
- JVM (Java Virtual Machine) executes bytecode.
- JDK (Java Development Kit), JRE (Java Runtime Environment).
2. Data Types
- Primitive: int, double, boolean, char, float, long, byte, short.
- Reference: Arrays, Strings, Objects.
3. OOP Concepts
- Encapsulation: Use private fields & getters/setters.
- Inheritance: Extending a class using 'extends'.
- Polymorphism: Method Overloading & Overriding.
- Abstraction: Use 'abstract' classes or 'interfaces'.
4. Control Statements
- if-else, switch-case.
- Loops: for, while, do-while.
- break & continue.
5. Arrays & Strings
- Array: int[] arr = {1,2,3};
- String Methods: length(), charAt(), substring(), split(), replace().
6. Exception Handling
try { int x = 10 / 0; }
catch (ArithmeticException e) { System.out.println(e.getMessage()); }
finally { System.out.println('Always executes'); }
7. File Handling (I/O)
- FileReader, FileWriter, BufferedReader, Scanner.
- Example: BufferedReader br = new BufferedReader(new FileReader('file.txt'));
8. Collections Framework
- List (ArrayList, LinkedList), Set (HashSet, TreeSet), Map (HashMap, TreeMap).
- Example: ArrayList<String> list = new ArrayList<>(); list.add('Hello');
9. JDBC (Java Database Connectivity)
- Steps: Load Driver -> Establish Connection -> Execute Query -> Close Connection.
- Example:
Connection con = DriverManager.getConnection('jdbc:mysql://localhost:3306/db', 'user', 'pass');
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery('SELECT * FROM table');

You might also like