Prakhar Singh

Java 101: Explore and Learn

Cover Image for Java 101: Explore and Learn
Prakhar Singh
Prakhar Singh

Java 101: Explore and Learn


1. Version Control (Git)


  • Git Basics: Repository setup, initialization (git init), tracking changes (git status, git log), committing (git add, git commit).

  • Branching & Merging: Creating and switching branches (git branch, git checkout, git switch), merging branches (git merge), and resolving merge conflicts.

  • Remote Repositories: Cloning (git clone), managing remotes (git remote), pushing and pulling changes (git push, git pull).

  • Collaboration & Best Practices: Distributed version control benefits, commit message conventions, and structuring branches for teams (feature, hotfix).

  • Git & Maven Integration: Maintaining proper Git workflows during builds and deployments.

2. Build Automation & Dependency Management (Maven)


  • Maven Basics: Project building lifecycle, anatomy of Maven, and the pom.xml file.

  • Dependency Management: Adding dependencies, utilizing the Maven Central Repository, and managing transitive dependencies.

  • Build Automation & Lifecycle: Maven phases (clean, compile, test, package, verify, install), plugins, and packaging applications into .jar or .war files.

3. Object-Oriented Programming (Java OOP)


  • OOP Pillars & Relationships: Encapsulation (data hiding, getters/setters), Inheritance (single, multilevel), Polymorphism, and Abstraction. "Has-A" (Composition) vs. "Is-A" (Inheritance) relationships.

  • Classes & Objects: Differences between classes and objects, object initialization, POJO (Plain Old Java Object), and concrete class vs. singleton class.

  • Constructors & Inheritance: Default vs. parameterized constructors, constructor overloading, constructor chaining, the this keyword, the super keyword, and super methods.

  • Polymorphism in Depth: Method overloading vs. method overriding (when to override and when to call), early binding (static) vs. late binding (dynamic method dispatching). Static methods can be inherited but not overridden (field hiding).

  • Abstraction & Interfaces: Abstract classes vs. interfaces (when to use which), implementation rules, types of interfaces (normal, marker, functional), and the Diamond Problem (how interfaces solve it).

  • Immutability & Object Design: How to make anything immutable, how to make a class truly immutable, defensive copying, and deep copy vs. shallow copy.

  • Nested & Inner Classes: Inner classes, nested classes, anonymous classes, anonymous inner classes, and static inner (nested) class vs. non-static inner class.

  • Access Modifiers: Understanding public, private, protected, and default scopes.

4. Core Java Fundamentals & Syntax


  • Data Types, Variables & Casting: Primitive vs. reference types, constants, literals, implicit/explicit type casting, and the Object vs Objects class.

  • Wrapper Classes & Autoboxing: What wrapper classes are, their internal workings, and Autoboxing vs. Unboxing.

  • Control Structures: Conditional statements (if-else, switch) and looping constructs (for, while, do-while, enhanced for-each).

  • Arrays: Single/multidimensional arrays, array initialization, and utility methods (Arrays.equals, Arrays.deepEquals, Arrays.deepToString, Arrays.toString).

  • String Manipulation: Immutable strings (String), mutable strings (StringBuffer vs StringBuilder), thread safety differences, key API methods.

  • Object Equality: The equals() method, hashCode() method, and the strict hashCode-equals contract.

5. Advanced Java Concepts & Memory Management


  • Keywords & Modifiers: Differences between final (and "effectively final"), finally block, and finalize() method. Usage of strictfp, volatile, and the static keyword (static variables, methods, blocks, and execution priority).

  • Exception Handling: Exception handling hierarchy, try-catch blocks, differences between throw and throws, custom exceptions.

  • Generics: Concept of Generics, Wildcards vs. Generics, exceptions in wildcards, and types of variance (Contravariant, Invariant, Covariant).

  • Multithreading & Concurrency: Concurrency and multithreading basics, the Runnable interface, ForkJoin pool, and AtomicInteger / other atomic data types.

  • JVM, Classloaders & Memory Model:

    text
      ~• Memory Structure: Stack vs. Heap memory, Metaspace, `Class<>` objects.
    
      ~• Garbage Collection: GC working algorithms, manual triggering via `System.gc`. Types of reference variables (strong, weak, phantom, soft).
    
      ~• Classloaders: ClassLoader Subsystem, delegation hierarchy (bootstrap, platform, application classloaders), dynamic class loading, and lazy loading.
    
  • Serialization & Reflection: The Serializable (marker interface) and Cloneable interfaces, how marker interfaces are internally serializable, the transient keyword, and the Reflections API.

  • Annotations: Built-in annotations (@Override, @Deprecated), what annotations are (@interface), where they are stored, and creating custom annotations.

6. Java Collections Framework & Data Structures


  • Collections Framework Basics: What the framework is (Collection vs Collections), advantages over arrays, Collection hierarchy. Iterable interface in collections, Iterable class.

  • Lists: What is a List? ArrayList vs. LinkedList (demonstrating differences, insertion working, complexity of operations), Vector, and working with legacy collections like Stack.

  • Sets: Internal working of Set (how it ensures no duplicates are added), HashSet vs. Keys of the HashMap, TreeSet vs. TreeMap, Navigable Set, and Abstract Set. Why you can't use the sort() method on a Set. Converting a Set to an array.

  • Queues: Real-world use cases, Queues vs. Stacks (can we implement a queue using a linked list? Can we implement a stack using a queue?). PriorityQueue, ArrayDeque.

  • Maps: Internal working of HashMap (hashing, collisions, treeify/untreefy), HashTable vs. HashMap, WeakHashMap vs. IdentityHashMap, HashMap vs. ConcurrentHashMap (internal working and demonstration).

  • Iteration & Traversal: Iterator vs Iterable, ListIterator, Spliterator (e.g., splitting a reversed list of fruits). Fail-fast vs. Fail-safe iterators.

  • Sorting & Comparators: Natural ordering (Comparable), custom logic (Comparator). Sorting a TreeMap in descending order. Sorting Maps by values (e.g., sorting a Map of Employee IDs to Marks).

  • Utility Classes & Operations: java.util.Collections, asList vs List.of vs Arrays.toList().

  • Practical Scenarios: Making two lists and performing union/intersection. Creating a custom class without overriding hashCode/equals and attempting to add those objects to a Set or Map.

7. Functional Programming & Streams (Java 8)


  • Lambda Expressions: Syntax, capturing variables, Lambda expression vs. anonymous class, and the concept of "effectively final."

  • Functional Interfaces: Core interfaces (Predicate, Function, Consumer, Supplier, BinaryOperator / Accumulator) and @FunctionalInterface.

  • Method References: Targeting static, instance, constructor, and arbitrary object methods.

  • The Streams API (Concepts): Declarative data processing, Streams vs. Collections, Streams vs. Parallel Streams. Upstream vs. Downstream in Java. Intermediate vs. Terminal operations.

  • Stream Operations & Collectors: findFirst vs. findAny, .toList() vs .collect(Collectors.toList()), and the difference between partitioningBy and groupingBy.

  • Practical Stream Applications:

    text
    - 1) Converting a List into a Map using streams.
    
    - 2) Using streams to sort a list of strings representing weekdays.
    
    - 3) Finding 2-digit numbers, adding their digits, and printing them in a sorted manner.
    
  • Null Handling: Preventing NullPointerException with Optional<T>.

8. Structural Improvements & Modularity (Java 17)


  • Records: Defining concise, immutable data objects. Passing Maps in records.

  • Sealed Classes: Restricting subclassing to a predefined list using the permits keyword for strict architectural boundaries.

9. Syntactic Advancements & New Features (Java 21)


  • Pattern Matching for switch: Simplifying conditions with type patterns and combining type checks with smart casts.

  • Unnamed Patterns & Variables: Using the underscore (_) for unused variables.

  • Unnamed Classes & Instance Main Methods: Simplifying prototypes and entry-point logic.

  • String Templates: Seamlessly injecting values into strings with placeholders (STR.).

  • Sequenced Collections: Maintaining insertion order for Maps and Sets efficiently with new interfaces.



Resources :


Git and Maven :


Object Oriented Programming :


Core Java Essentials :


Collections Framework :


Key Java Features:


Keep exploring and learning. Refer back to these topics whenever you need a quick recap, and always trust the official docs to guide you through the rest of your Java journey. Happy coding!