Programming and Java Fundamentals

Introduction to Java

ReadingPreview

You are viewing a free preview lesson.

Lesson Overview

Java is a high-level, general-purpose, statically typed, and class-based programming language with strong support for object-oriented programming.

Java is used to build everything from small command-line programs to backend services, banking platforms, e-commerce applications, and large distributed systems.

In this lesson, we will learn:

  • What Java is
  • A brief history of Java
  • Important characteristics of Java
  • What the Java ecosystem is
  • Where Java is used
  • Why Java is popular for backend development
  • Some benefits and challenges of learning Java

Learning Objectives

After completing this lesson, you will be able to:

  • Explain what type of programming language Java is
  • Identify important characteristics of Java
  • Understand where Java is used
  • Explain the relationship between the Java language, JDK, and JVM at a basic level
  • Understand the importance of Java in backend development
  • Describe some benefits and trade-offs of learning Java

What Is Java?

Java is a:

  • High-level language
  • General-purpose language
  • Statically typed language
  • Class-based language

Java provides strong support for object-oriented programming.

A simple Java program:

public class Main {

    public static void main(String[] args) {
        System.out.println("Hello Java");
    }
}

Output:

Hello Java

You do not need to understand every part of this code yet. In the following lessons, we will learn Java syntax, methods, classes, and objects step by step.

General-Purpose Language

A general-purpose language is not designed for only one specific type of task.

Java can be used to build:

  • Command-line applications
  • Backend services
  • REST APIs
  • Web applications
  • Financial systems
  • E-commerce platforms
  • Data processing applications
  • Distributed systems

This means Java is not a language limited to one specific domain.

Statically Typed Language

Java is a statically typed language.

This means the types of variables and expressions are checked at compile time.

int age = 25;
String name = "Sakib";

Here, age is an integer and name is a String.

The following code is not valid:

int age = "twenty-five";

The compiler can detect that a text value is being assigned to an int variable.

Static typing allows many types of errors to be detected before the program runs. It can also make refactoring and maintenance easier in large codebases.

Class-Based and Object-Oriented Programming

A large part of Java code is structured using classes.

Example:

public class Student {

    String name;
    int age;
}

Here, Student is a class that represents the structure of student-related data.

Using Java, we can model different concepts in software, such as:

  • Student
  • Course
  • Product
  • Order
  • BankAccount
  • Payment

In later modules, we will learn step by step, starting with classes and objects, and then covering:

  • Encapsulation
  • Composition
  • Inheritance
  • Abstraction
  • Interface
  • Polymorphism

The goal of this course is not only to learn Java syntax, but also to learn how to design maintainable object-oriented software using Java.

A Brief History of Java

Java development began in the early 1990s at Sun Microsystems through James Gosling and his team.

The language was originally called:

Oak

It was later renamed Java and was publicly released in 1995.

Some of the important goals behind Java included:

  • Building portable software
  • Running code on different platforms
  • Providing a managed runtime environment
  • Reducing some of the low-level complexity of C and C++

Over time, Java became widely used in enterprise and server-side software development.

Java Language, JDK, and JVM

When understanding the Java ecosystem, it is useful to distinguish between three terms:

Java Language

The syntax and programming rules developers use to write source code.

JDK

JDK — Java Development Kit is the toolset needed to develop Java applications.

It includes the compiler and other development-related tools.

JVM

JVM — Java Virtual Machine executes compiled Java bytecode.

In the previous lesson, we saw the Java execution flow:

Java Source Code
        ↓
Compiler
        ↓
Bytecode
        ↓
JVM
        ↓
Running Program

This architecture is the foundation of Java application's portability and managed runtime model.

OpenJDK

OpenJDK is the open-source implementation of the Java platform.

Different vendors in the Java ecosystem may provide JDK distributions based on OpenJDK.

As a beginner, vendor differences are not important yet.

The main point is:

A compatible JDK is required to develop and run Java applications.

Important Characteristics of Java

Several characteristics of Java have made it suitable for production software development.

Readable and Explicit

Java syntax is relatively explicit.

int price = 500;
int quantity = 2;
int total = price * quantity;

By reading the code, it is easy to understand the variable types and the calculation.

This explicitness can be useful in large teams and large codebases.

The trade-off is that Java can be more verbose than some other languages.

Platform Portability

The Java compiler generates bytecode, and a compatible JVM can execute that bytecode.

Because of this model, the same compiled Java application may be able to run on different operating systems.

However, if an application uses native libraries or operating-system-specific dependencies, portability may be limited.

Strong Type System

Java's type system helps detect many invalid operations at compile time.

Example:

int quantity = 10;
String productName = "Keyboard";
boolean available = true;

Type information:

  • Helps developers understand code
  • Improves IDE support
  • Makes refactoring safer
  • Makes method contracts clearer
  • Helps maintain large codebases

Automatic Memory Management

The JVM manages memory for Java applications.

Developers generally do not need to manually allocate and free memory.

The JVM uses Garbage Collection to reclaim memory from unused objects.

This reduces the complexity of low-level memory management.

However, automatic memory management does not mean that developers never need to think about memory. In production applications, allocation, object lifetime, and memory usage can still be important.

Standard Library

Java provides a rich standard library.

Built-in APIs are available for common functionality such as:

  • String processing
  • Collections
  • File handling
  • Date and time
  • Networking
  • Concurrency
  • Input/output
  • Security

Example:

String name = "Java";

System.out.println(name.length());

Output:

4

Here, String and length() are part of Java's standard library.

Mature Ecosystem

A large production ecosystem has developed around Java over many years.

Popular technologies include:

  • Spring Boot
  • Hibernate
  • Maven
  • Gradle
  • JUnit
  • Mockito
  • Jackson
  • Kafka client

These technologies make tasks such as application development, persistence, testing, build automation, and integration easier.

This is why it is important to understand core Java well before learning frameworks.

Concurrency Support

Java provides built-in language and library support for concurrent programming.

Backend applications may need to handle many requests or background tasks at the same time.

Concurrency is an advanced topic, so you do not need to understand its implementation at this stage. However, it is an important concept in production Java development.

Where Is Java Used?

Java is used in many types of software systems.

Backend and API Development

Java is widely used for building server-side applications.

A backend application typically:

  • Receives HTTP requests
  • Executes business logic
  • Works with databases
  • Handles authentication and authorization
  • Communicates with other services
  • Produces API responses

Spring Boot is a widely used framework for Java backend development.

Enterprise and Financial Systems

Java has been used in enterprise software for many years.

Examples include:

  • Banking
  • Payment processing
  • Insurance
  • Telecom
  • E-commerce
  • Healthcare
  • Large internal business systems

These types of applications often need to be maintained for a long time, where reliability, tooling, and backward compatibility are important.

Distributed Systems

Java can be used to build services that work together over a network.

Examples:

  • Microservices
  • Message consumers
  • Background workers
  • Event-driven services
  • Data processing services

The Java ecosystem integrates well with technologies such as Kafka, gRPC, Spring, and various networking libraries.

Android and Desktop Applications

Java was an important language for Android development for many years. Although Kotlin is now prominent, Java is still relevant in the existing Android ecosystem.

Java can also be used to build desktop applications using Swing or JavaFX.

However, the main focus of this course is the foundation of backend engineering.

Why Is Java Popular for Backend Development?

Java has remained popular in backend development for many years for several practical reasons.

Mature Ecosystem

The Java ecosystem is built on decades of production experience.

Developers have access to:

  • Mature frameworks
  • Established libraries
  • Strong tooling
  • A large community
  • Extensive production knowledge

Strong Framework Support

Frameworks such as Spring Boot make it easier to build production backend applications using Java.

They can be used for:

  • REST APIs
  • Database integration
  • Validation
  • Authentication
  • Messaging
  • Configuration
  • Monitoring

However, understanding framework abstractions requires a strong core Java foundation.

Performance

Modern JVMs can provide strong runtime performance for long-running server applications.

However, application performance does not depend only on the programming language.

Performance is also affected by:

  • Algorithms
  • Data structures
  • Database queries
  • Network latency
  • Memory allocation
  • Concurrency design
  • Application architecture

Maintainability

Java's static typing and explicit structure help maintain large codebases.

Example:

public int calculateTotal(int price, int quantity) {
    return price * quantity;
}

From the method signature alone, we can understand that:

  • Two int inputs are required
  • An int result is returned

This kind of clear contract is valuable in large teams.

Tooling

The Java ecosystem has strong IDE support.

In particular, IDEs such as IntelliJ IDEA help with:

  • Code completion
  • Compile-time error detection
  • Refactoring
  • Debugging
  • Test execution
  • Dependency navigation

In large application development, tooling plays an important role in developer productivity and code safety.

Benefits of Learning Java

Learning Java builds a foundation not only in one language, but also in several transferable software engineering concepts.

Examples include:

  • Types
  • Variables
  • Control flow
  • Methods
  • Classes and objects
  • Interfaces
  • Error handling
  • Collections
  • Generics
  • Concurrency

This knowledge is also useful when learning other programming languages and backend technologies later.

Java is also a practical foundation for production backend engineering.

Challenges of Learning Java

Java can be beginner-friendly, but it also has some challenges.

Syntax Can Be Relatively Verbose

Even simple tasks can sometimes require more syntax than in other languages.

Java:

System.out.println("Hello");

Python:

print("Hello")

Although Java's explicitness can increase verbosity in some cases, it can also help keep structure clear in large codebases.

Many New Terms Appear at the Beginning

A first Java program:

public class Main {

    public static void main(String[] args) {
        System.out.println("Hello");
    }
}

A beginner sees many unfamiliar terms at once.

Examples:

  • public
  • class
  • static
  • void
  • String

You do not need to memorize these immediately. The course will introduce them step by step in the correct sequence.

A Strong Foundation Is Needed Before Frameworks

If you start directly with Spring Boot without understanding Java syntax and OOP, the code may work, but it can be difficult to understand the underlying behavior.

In particular, concepts such as:

  • Object creation
  • Interface
  • Exception
  • Generics
  • Dependency
  • Method invocation

are important for understanding framework abstractions.

This is why we will first build a strong Java and OOP foundation.

Java and JavaScript Are Not the Same

Despite the similarity in their names, Java and JavaScript are two different programming languages.

Java is generally more associated with the JVM ecosystem and backend or enterprise development.

JavaScript is the primary language for browser-based frontend development and is also used for backend development through Node.js.

Their runtimes, type systems, ecosystems, and execution models are different.

Important Terms

Java

A high-level, general-purpose, statically typed, and class-based programming language.

General-Purpose Language

A programming language that can be used for different types of problems and applications.

Statically Typed

A language in which type information is checked at compile time.

Class-Based

A programming model in which classes are important building blocks of program structure.

Object-Oriented Programming

An approach to modeling and designing software through objects and their responsibilities.

JDK

A collection of the compiler and other development tools used to develop Java applications.

JVM

The runtime environment that executes Java bytecode.

OpenJDK

The open-source implementation of the Java platform.

Standard Library

Reusable built-in classes and APIs provided with Java.

Ecosystem

The frameworks, libraries, tools, and community surrounding a language.

Practice Exercise 1: Identify Java Characteristics

Write which Java characteristic is most closely related to each description below.

  1. Variable types are checked at compile time.
  2. The JVM can reclaim memory from unused objects.
  3. Software can be modeled using classes and objects.
  4. Built-in APIs are available for common tasks.
  5. Compiled Java code can run on different platforms using compatible JVMs.

Possible answers:

  • Static typing
  • Automatic memory management
  • Object-oriented programming
  • Standard library
  • Platform portability

Practice Exercise 2: Where Can Java Be Used?

For any three of the following systems, briefly describe what kind of backend responsibilities Java could handle:

  • Banking system
  • Learning platform
  • E-commerce application
  • Food delivery application
  • Payment service

Practice Exercise 3: Observe the Code

Look at the following code:

public class Product {

    String name;
    int price;
}

Answer:

  1. What is the name of the class?
  2. How many fields are there?
  3. What are the names of the fields?
  4. Which field stores text?
  5. Which field stores an integer?

Knowledge Check

Question 1

What type of programming language is Java?

Question 2

What does statically typed language mean?

Question 3

What does it mean that Java is class-based?

Question 4

What are the roles of the JDK and JVM?

Question 5

What are three reasons Java is popular for backend development?

Question 6

What does automatic memory management mean?

Question 7

Are Java and JavaScript the same language?

Knowledge Check Answers

Answer 1

Java is a high-level, general-purpose, statically typed, and class-based programming language with strong support for object-oriented programming.

Answer 2

In a statically typed language, the types of variables and expressions are checked at compile time.

Answer 3

Classes are important building blocks for structuring Java applications. Classes can be used to organize data and behavior.

Answer 4

The JDK provides the tools needed to develop Java applications. The JVM executes compiled Java bytecode.

Answer 5

Java's mature ecosystem, static type system, strong framework support, runtime performance, and tooling are important reasons for its popularity in backend development.

Answer 6

Automatic memory management means that the JVM can reclaim memory from unused objects, so developers generally do not need to manually free memory.

Answer 7

No. Java and JavaScript are two different programming languages.

Lesson Summary

In this lesson, we learned:

  • Java is a high-level, general-purpose, and statically typed language
  • Java is class-based and provides strong support for object-oriented programming
  • Java was created at Sun Microsystems and was originally known as Oak
  • The JDK provides development tools, while the JVM executes Java bytecode
  • Java provides automatic memory management and a rich standard library
  • Java has a mature ecosystem of frameworks, libraries, and tools
  • Java is widely used in backend, enterprise, financial, and distributed systems
  • Static typing, maintainability, tooling, and ecosystem make Java suitable for backend development
  • It is important to build a strong core Java and OOP foundation before learning frameworks
  • Java and JavaScript are two different programming languages