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

Java Quick Reference Sheet

The document outlines fundamental programming concepts including variables, data types, typecasting, operators, control flow, arrays, and methods. It also covers object-oriented principles such as classes, inheritance, polymorphism, encapsulation, and exception handling. Additionally, it introduces advanced topics like generics, lambda expressions, and the collection framework.
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 views3 pages

Java Quick Reference Sheet

The document outlines fundamental programming concepts including variables, data types, typecasting, operators, control flow, arrays, and methods. It also covers object-oriented principles such as classes, inheritance, polymorphism, encapsulation, and exception handling. Additionally, it introduces advanced topics like generics, lambda expressions, and the collection framework.
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/ 3

1.

Variables & Data Types

Variables hold data.

Example:

int age = 20;

String name = "John";

Data Types: int, float, boolean, char, String, etc.

2. Typecasting

Convert one type to another.

Example:

double d = 9.7;

int i = (int) d; // i = 9

3. Operators

Arithmetic: +, -, *, /, %

Assignment: =, +=, -=

Unary: ++, --

Comparison: ==, !=, <, >

Logical: &&, ||, !

Ternary:

int max = (a > b) ? a : b;

4. Control Flow

if, else if, else:

if (a > b) {...} else {...}

Switch:

switch(day) { case 1: ... break; }

5. Arrays

1D: int[] nums = {1, 2, 3};


2D: int[][] matrix = {{1,2}, {3,4}};

6. Math & Strings

Math: Math.max(5,10);

String: "Hello".length();

7. StringBuilder

StringBuilder sb = new StringBuilder("Hi");

sb.append(" there");

8. Classes & Attributes

class Car {

String color;

9. Methods

void drive() {

System.out.println("Driving...");

10. Use Case Diagram

Describes user-system interaction (visual, not code).

11. Package & Access Modifiers

package: group of classes

Access: public, private, protected, default

12. Encapsulation

Private variables with public getters/setters.

13. Constructor

Car(String c) { color = c; }

14. Inheritance
class Dog extends Animal {}

15. Polymorphism

Method overriding:

class A { void show() {} }

class B extends A { void show() {} }

16. Abstract Class

abstract class Shape { abstract void draw(); }

17. Interface

interface Flyable { void fly(); }

18. Exception Handling

try { int x = 10 / 0; } catch (Exception e) { System.out.println("Error"); }

19. Collection Framework

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

20. Generics

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

21. Lambda Expressions

(a, b) -> a + b

You might also like