Skip to main content

Java

Courses

Setup

  • Check for installed java version

    java --version

    Command 'javac' not found, but can be installed with:
    sudo apt install openjdk-11-jdk-headless  # version 11.0.6+10-1ubuntu1~19.10.1, or
    sudo apt install default-jdk              # version 2:1.11-72
    sudo apt install openjdk-8-jdk-headless   # version 8u242-b08-0ubuntu3~19.10
    sudo apt install ecj                      # version 3.16.0-1
    sudo apt install openjdk-13-jdk-headless  # version 13+33-1
    sudo apt install openjdk-14-jdk-headless  # version 14~18-1
  • Install

      sudo apt install openjdk-11-jdk
  • IntelliJ IDEA

    • Project (RightClick) -> Open Module Settings -> SDK

OOPS

Inheritance

  • Java - extends
  • Laptop - Gaming Laptop - Work Laptop

Composition

  • Laptop - CPU - RAM

Encapsulation

  • access specifier

Polymorphism

  • overload
    • functions same name, different parameters
  • override
    • change behaviour of function in children classes

Abstraction

  • Java
    • abstract function
    • interface - implements

Anonymous classes

  • overriding a single object