DIT3104: JAVA PROGRAMMING
COMPLETE STUDENT NOTES
Introduction to Java
Java is a high-level, object-oriented, platform-independent programming language. It follows the
principle Write Once, Run Anywhere using the Java Virtual Machine (JVM).
Java Features
Object-Oriented, Platform Independent, Secure, Robust, Portable, Multithreaded.
JVM, JRE and JDK
JVM executes bytecode. JRE provides runtime environment. JDK is used to develop Java
programs.
Basic Java Program
Example:
class HelloWorld { public static void main(String[] args) { [Link]("Hello World"); } }
Data Types
Primitive data types include int, float, double, char and boolean.
Variables and Constants
Variables store data. Constants are declared using the final keyword.
Operators
Arithmetic, Relational, Logical, Assignment and Ternary operators are used in Java.
Control Flow
Decision making statements include if, if-else, nested if and switch-case.
Loops
Java supports for, while and do-while loops for repetition.
Object Oriented Programming
OOP concepts include Classes, Objects, Encapsulation, Inheritance, Polymorphism and
Abstraction.
Constructors
Constructors initialize objects and have the same name as the class.
Inheritance
Inheritance allows a class to acquire properties of another class using extends keyword.
Polymorphism
Polymorphism allows one method to perform different tasks using overloading and overriding.
Abstract Classes and Interfaces
Abstract classes contain abstract methods. Interfaces support multiple inheritance.
Arrays of Objects
Java allows creation of arrays that store objects.
Exception Handling
Java uses try, catch, finally, throw and throws for error handling.
File Handling
Java supports file input and output using File, FileReader and FileWriter classes.
Exam Tips
Understand definitions, write clean programs, and practice OOP examples.