[go: up one dir, main page]

0% found this document useful (0 votes)
10 views7 pages

Java Basics

The document introduces Java as a high-level, object-oriented programming language that is platform-independent due to the Java Virtual Machine (JVM). It explains the core principles of Object-Oriented Programming (OOP), including abstraction, encapsulation, inheritance, and polymorphism, and provides a guide on setting up the Java Development Kit (JDK) on Windows. Additionally, it outlines the structure of Java code and the features of Integrated Development Environments (IDEs), with examples of popular IDEs for Java development.

Uploaded by

melody.david
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)
10 views7 pages

Java Basics

The document introduces Java as a high-level, object-oriented programming language that is platform-independent due to the Java Virtual Machine (JVM). It explains the core principles of Object-Oriented Programming (OOP), including abstraction, encapsulation, inheritance, and polymorphism, and provides a guide on setting up the Java Development Kit (JDK) on Windows. Additionally, it outlines the structure of Java code and the features of Integrated Development Environments (IDEs), with examples of popular IDEs for Java development.

Uploaded by

melody.david
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/ 7

🧑🏽‍🏫 Java Programming-I

📘 Session 1: Introduction to Java


Java is a high-level, object-oriented programming language developed by Sun
Microsystems (now owned by Oracle).
It's platform-independent thanks to the Java Virtual Machine (JVM), meaning you can
write code once and run it anywhere.

📱 Popular Apps Built with Java


●​ Twitter (originally built with Java on the backend)​

●​ Spotify (uses Java for backend and data processing)​

●​ Netflix (uses Java for backend microservices)​

●​ Minecraft (desktop version is built with Java)​

●​ Android Apps (many are developed in Java using Android Studio)

What is OOP?
OOP (Object-Oriented Programming) is a programming paradigm based on the concept of
"objects", which are instances of classes.

* Object​
An object is an instance of a class that holds data and behavior.​
It represents a real-world entity like a student, car, or account.​
Example of object is Dog

​ * Property - Color, Age

​ * Action - Barking, eating, running

* Class​
A class is a template or blueprint for creating objects.​
It defines variables (field), functions (method), states and behaviour of all objects
belonging to that class.
🔑 4 Core Principles of OOP:
3. Abstraction​
Abstraction hides complex implementation and shows only essential features.​
It helps reduce complexity by exposing only what’s necessary.

4. Encapsulation​
Encapsulation binds data and methods into a single unit (class).​
It restricts direct access to internal data using access modifiers (like private).

5. Inheritance​
Inheritance allows a class to inherit properties and methods from another class.​
It promotes code reuse and establishes a parent-child relationship.

6. Polymorphism​
Polymorphism means one function or object can behave in many ways.​
It enables method overriding (runtime) and method overloading (compile-time).

☕ What is JDK? - Part of Java component


JDK (Java Development Kit) is a software development kit provided by Oracle and
others that allows you to develop and run Java applications.

👉 Oracle JDK (Latest Version):​


https://www.oracle.com/java/technologies/javase-downloads.html


To set the JAVA_HOME environment variable on Windows, follow these
steps:

✅ Step-by-Step: Set JAVA_HOME on Windows


🔹 1. Find your JDK installation path
For example, it might be:

C:\Program Files\Java\jdk-21
You must copy the JDK folder path — not the bin folder.

🔹 2. Open Environment Variables


1.​ Press Windows + S, search for Environment Variables and click on:​
“Edit the system environment variables”​

2.​ In the System Properties window, click on:​


“Environment Variables…”​

🔹 3. Create the JAVA_HOME variable


Under System variables:

1.​ Click New​

In Variable name, enter:​



JAVA_HOME

2.​

In Variable value, paste the JDK path:​



C:\Program Files\Java\jdk-21

3.​
4.​ Click OK​

🔹 4. Update the Path variable


Still under System variables:

1.​ Find the variable named Path​

2.​ Select it and click Edit​

Click New and add:​



%JAVA_HOME%\bin

3.​
4.​ Click OK, then again to close all dialogs​

🔹 5. Verify it works
Open Command Prompt and run:

java -version
javac -version
echo %JAVA_HOME%

Java Structure

🧩 Structure Breakdown
1.​ Package – Organizes classes into namespaces. Optional if you're just starting.​

2.​ Import – Brings in classes from Java libraries (e.g., Scanner for user input).​

3.​ Class – Every Java code must be inside a class. It's the main container.​

4.​ Field - Store object data (e.g., name, age)​


5.​ Constructor - Initializes objects when they created​

6.​ Main Method – Java starts execution from public static void main(String[]
args).​

7.​ Statements – Your logic, like printing, calculations, or function calls.

How to save java code file


To save java code, you must use .java​
Note that it is case sensitive.​
Example- helloworld.java.​
You can save with any name you wish, so far you add it with .java
💡 What is an IDE?
💡 What is an IDE?
IDE stands for Integrated Development Environment.

It's a software application that provides a complete set of tools to write, edit, test, and debug
code all in one place — making programming easier and faster.

🧰 Key Features of an IDE:


●​ Code Editor – where you write your code​

●​ Compiler/Interpreter – to convert your code into something the computer can run​

●​ Debugger – to find and fix errors in your code​

●​ Build Tools – to compile, run, and package your programs​

●​ Auto-complete – helps you write code faster with suggestions​

✅ Examples of IDEs:
●​ NetBeans – for Java, C++, etc.​

●​ IntelliJ IDEA – advanced Java IDE​

●​ Eclipse – widely used for Java and Android​

●​ Android Studio – for Android apps​

●​ Visual Studio – for C#, .NET, etc.​


.

We are going to use NetBeans today, but when we want to build mobile apps, we will
use Android Studio.

👉
Official download:
https://netbeans.apache.org/


Assignment..​
Read on-
1.​ Java platform and it’s component - JVM, JRE, JDK
2.​ Comments in Java

You might also like