0% found this document useful (0 votes)
17 views

Java Module I

The document outlines the Java Programming course for the academic year 2024-25 at Aurora University, detailing objectives, course outcomes, prior knowledge, prerequisites, and a comprehensive syllabus covering various Java concepts. Key modules include Java architecture, object-oriented programming, inheritance, exception handling, JDBC, multithreading, and GUI programming with Swing and JavaFX. The document also provides a brief history of Java, its versions, features, and recommended textbooks and readings.

Uploaded by

jayasri
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views

Java Module I

The document outlines the Java Programming course for the academic year 2024-25 at Aurora University, detailing objectives, course outcomes, prior knowledge, prerequisites, and a comprehensive syllabus covering various Java concepts. Key modules include Java architecture, object-oriented programming, inheritance, exception handling, JDBC, multithreading, and GUI programming with Swing and JavaFX. The document also provides a brief history of Java, its versions, features, and recommended textbooks and readings.

Uploaded by

jayasri
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 45

AURORA DEEMED TO BE

UNIVERSITY
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING

JAVA PROGRAMMING
(JP)
B.Tech. – CSE / AIML / DS
BBA / BCA
Academic Year : 2024-25
Term – I
MODULE-I
Compiled by Ms. K. Jayasri, CSE,
03/23/25 1
Aurora University
Compiled by Ms. K. Jayasri, CSE,
03/23/25 2
Aurora University
Objectives
1.Explain object oriented concepts in Java
2.Identify suitable inhertiance for real world
applications and demonstrate packages.
3.Develop database applications using JDBC
4.Build applications capable for multitasking.
5.Develop GUI applications using Swing and
JavaFX

Compiled by Ms. K. Jayasri, CSE,


03/23/25 3
Aurora University
Course Outcomes
After completion of this course successfully, the students will be able to

CO1: Understand Java architecture, class and object fundamentals, constructors,


and method overloading.

CO2: Apply concepts of inheritance, abstract classes, packages, and interfaces,


including access protection and static methods.

CO3: Implement exception handling and multithreading, including


synchronization and inter-thread communication.

CO4: Utilize auto boxing, annotations, and JDBC for effective database
connectivity and management.

CO5: Develop GUIs using Swing and JavaFX, understanding and employing
their basic components and controls.

Compiled by Ms. K. Jayasri, CSE,


03/23/25 4
Aurora University
Prior- Knowledge
Object Oriented Programming.

Pre –Requisites
Programming IDEs

Compiled by Ms. K. Jayasri, CSE,


03/23/25 5
Aurora University
SYLLABUS
Module 1: Overview of Java:
Java Architecture, JVM Components, Class and Object fundamentals, String classes,
Constructors, This keyword, the Finalized( ) method.

Module 2: A closer look at methods and classes:


Overloading methods, A closer look at Argument passing, Introducing Access
Control, Overloading Vararg Methods, Nested and Inner Classes.

Module 3: Inheritance and polymorphism


A Superclass variable can reference a subclass object, Using super, Method
Overriding, Using Abstract classes, Final with inheritance, Abstract Classes and
Dynamic Method Dispatch.

Module 4: Packages and Interfaces


Finding packages and CLASSPATH, Access protection, Variable in interfaces,
Interfaces can be Extended, Use static methods in an Interface,Nesting of Interface.

Module 5: Exception Handling


Exception Handling Fundamentals, Exception types, creating your own exception,
subclasses, chained exceptions.
Compiled by Ms. K. Jayasri, CSE,
03/23/25 6
Aurora University
SYLLABUS
Module 6: JDBC
JDBC Architecture, JDBC API and Drivers, Types of Statements, Result set, CURD
Operations.

Module 7: Multithreaded Programming


The Thread class and the Runnable interface, creating multiple threads using isAlive( )
and
join(), Inter thread communication( Suspending, Resuming and stoppingThreads),
Synchronization.

Module 8: Autoboxing and Annotations


Enumerations, Auto boxing and methods, Auto boxing/unboxing occurs in Expression,
The Annotated Element Interface, Marker annotation.

Module 9: Introducing GUI Programming with swing:


The origin of Swing, MVC Connection, Exploring swing, swing Buttons, swing menus,
Swing Packages.

Module 10: Introducing GUI Programming with JavaFX


JavaFX Basic concepts, JavaFX application Skeleton, Introducing the Button Control,
Demonstrating Event Handling .
Compiled by Ms. K. Jayasri, CSE,
03/23/25 7
Aurora University
Text Book:
1. Schildt, Herbert. Java: the complete reference. McGraw-Hill Education Group,
2014.

2. Liang, Y. D. (2020). Java programming and data structures Twelfth Edition.

3. Core Java Volume I – Fundamentals and II - Advanced features by Cay S.


Horstmann and Gary Cornell.

SUGGESTED READING

1.E. Balagurusamy, “Programming with Java: A Primer”, Tata McGraw-Hill,


2010.
2.Sierra, Kathy, and Bert Bates. Head First Java: A Brain-Friendly Guide.OReilly
Media, Inc;, 2005.
3.Bloch, Joshua. Effective java (the java series). Prentice Hall PTR, 2008.
4.Goetz, Brian. Java concurrency in practice. Pearson Education, 2006.
5.Loy, Marc, Robert Eckstein, Dave Wood, James Elliott, and Brian Cole. Java
swing. OReilly Media, Inc 2002.

Compiled by Ms. K. Jayasri, CSE,


03/23/25 8
Aurora University
Module 1: Overview of Java
•Java Architecture
•JVM Components
•Class and Object fundamentals

•String classes

•Constructors

•This keyword
•the Finalized( ) method.
Compiled by Ms. K. Jayasri, CSE,
03/23/25 9
Aurora University
Introduction to Java
•Java is an Object-Oriented
programming language developed
by James Gosling in the early
1990s, later acquired by Oracle
Corporation.

•It is high level programming • It was developed


language. Writing, compiling and by James Gosling
debugging a program is easy in and his team.
java.

• It helps to create modular


programs and reusable code.
Compiled by Ms. K. Jayasri, CSE,
03/23/25 10
Aurora University
History of Java
1) James Gosling, Mike Sheridan, and Patrick Naughton initiated the Java
language project in June 1991. The small team of sun engineers
called Green Team.
2) Initially it was designed for small, embedded systems in electronic
appliances like set-top boxes.
3) Firstly, it was called "Greentalk" by James Gosling, and the file
extension was .gt.
4) After that, it was called Oak and was developed as a part of the Green
project.(Oak is a symbol of strength and chosen as a national tree of many
countries like the U.S.A., France, Germany, Romania, etc.)
5) In 1995, Oak was renamed as "Java" because it was already a trademark
by Oak Technologies.
6) Java is an island in Indonesia where the first coffee was produced
(called Java coffee). It is a kind of espresso bean. Java name was chosen by
James Gosling while having a cup of coffee nearby his office.

Compiled by Ms. K. Jayasri, CSE,


03/23/25 11
Aurora University
Usage of Java

Java is widely used in

•Android development,
•web applications,
•governmental websites, big data technologies like
Hadoop and Apache Storm, and
•scientific projects like natural language processing.
It has been a dominant player in the mobile industry
since the early 2000s.

Compiled by Ms. K. Jayasri, CSE,


03/23/25 12
Aurora University
Compiled by Ms. K. Jayasri, CSE,
03/23/25 13
Aurora University
Java Versions

Java has gone through several major versions since its inception.
Here's a brief overview of the key versions
1.Java 1.0 (1996) - The original release, introducing core language
features and the Java Virtual Machine (JVM).
2.Java 1.1 (1997) - Added features like inner classes, JavaBeans,
and the event model.
3.Java 2 (Java 1.2) (1998) - Major overhaul with the introduction
of the Collections Framework, Swing GUI toolkit, and more.
4.Java 5 (Java 1.5) (2004) - Introduced generics, metadata
annotations, enumerated types, and enhanced for-loops.
5.Java 6 (2006) - Focused on performance improvements, scripting
support via the Java Compiler API, and enhancements to web
services.
6.Java 7 (2011) - Introduced features like the try-with-resources
statement, diamond operator, and improved exception handling.
Compiled by Ms. K. Jayasri, CSE,
03/23/25 14
Aurora University
Java Versions
• Java 8 (2014) - Major update introducing lambda
expressions, the Stream API, and the new Date and Time
API.
• Java 9 (2017) - Introduced the module system (Project
Jigsaw), JShell (REPL), and improved Javadoc.
• Java 10 (2018) - Included local-variable type inference (var)
and improvements in the garbage collector.
• Java 11 (2018) - Long-Term Support (LTS) release with
features like the HTTP Client and removal of some
deprecated features.
• Java 12 (2019) - Added features like switch expressions
(preview) and a new garbage collector (Shenandoah).
• Java 13 (2019) - Included text blocks (preview) and
improvements to the switch expression.

Compiled by Ms. K. Jayasri, CSE,


03/23/25 15
Aurora University
Java Versions

• Java 14 (2020) - Introduced records (preview) and pattern matching for


instanceof (preview).
• Java 15 (2020) - Added sealed classes (preview) and more enhancements to
garbage collection.
• Java 16 (2021) - Another LTS version, bringing in new features like JEP 338
(Vector API, incubating) and the new packaging tool.
• Java 17 (2021) - Current LTS release with features like sealed classes,
pattern matching for instanceof, and enhanced switch expressions.
• Java 18 (2022) - Introduced features like simple web server and code
snippets in Java.
• Java 19 (2022) - Added preview features like virtual threads and pattern
matching for switch.
• Java 20 (2023) - Continued to refine features like virtual threads and added
new preview features.
The Java platform is continually evolving, with regular updates introducing new
features, improvements, and deprecations. Each version typically focuses on
enhancing performance, security, and developer productivity.
Compiled by Ms. K. Jayasri, CSE,
03/23/25 16
Aurora University
History Of Java Versions

Compiled by Ms. K. Jayasri, CSE,


03/23/25 17
Aurora University
Compiled by Ms. K. Jayasri, CSE,
03/23/25 18
Aurora University
History Of Java Versions

Compiled by Ms. K. Jayasri, CSE,


03/23/25 19
Aurora University
Features of Java [BuZZWords]

The main objective of Java programming language creation was to


make it portable, simple and secure programming language. Apart
from this, there are also some awesome features which play
important role in the popularity of this language. The features of
Java are also known as java buzzwords.

Compiled by Ms. K. Jayasri, CSE,


03/23/25 20
Aurora University
Compiled by Ms. K. Jayasri, CSE,
03/23/25 21
Aurora University
Simple
Java is very easy to learn and its syntax is simple,
clean and easy to understand. According to Sun, Java
language is a simple programming language because:


Java syntax is based on C++ (so easier for programmers to
learn it after C++).
Java has removed many confusing and rarely-used features

e.g. explicit pointers, operator overloading etc.



There is no need to remove unreferenced objects because
there is Automatic Garbage Collection in java.

Compiled by Ms. K. Jayasri, CSE,


03/23/25 22
Aurora University
Object-oriented
Java is object-oriented programming language. Everything in Java is an
object. Object-oriented means we organize our software as a combination
of different types of objects that incorporates both data and behaviour.

Object-oriented programming (OOPs) is a methodology that simplifies


software development and maintenance by providing some rules.

Basic concepts of OOPs are:


1.Object
2.Class
3.Inheritance
4.Polymorphism
5.Abstraction
6.Encapsulation

Compiled by Ms. K. Jayasri, CSE,


03/23/25 23
Aurora University
Platform Independent

Compiled by Ms. K. Jayasri, CSE,


03/23/25 24
Aurora University
Java is platform independent because it is different from other
languages like C, C++ etc. which are compiled into platform
specific machines while Java is a write once, run anywhere
language. A platform is the hardware or software environment
in which a program runs.
There are two types of platforms software-based and hardware-
based. Java provides software-based platform.
The Java platform differs from most other platforms in the sense
that it is a software-based platform that runs on the top of other
hardware-based platforms. It has two components:
1.Runtime Environment
2.API(Application Programming Interface)
Java code can be run on multiple platforms e.g. Windows, Linux,
Sun Solaris, Mac/OS etc. Java code is compiled by the compiler
and converted into bytecode. This bytecode is a platform-
independent code because it can be run on multiple platforms
i.e. Write Once and Run
03/23/25
Anywhere(WORA).
Compiled by Ms. K. Jayasri, CSE,
25
Aurora University
Secured
Java is best known for its security. With Java, we can develop
virus-free systems.
Java is secured because:
•No explicit pointer
•Java Programs run inside virtual machine sandbox

Compiled by Ms. K. Jayasri, CSE,


03/23/25 26
Aurora University
Robust
Robust simply means strong. Java is robust because:

It uses strong memory management.

There are lack of pointers that avoids security problems.

There is automatic garbage collection in java which runs on
the Java Virtual Machine to get rid of objects which are not
being used by a Java application anymore.

There is exception handling and type checking mechanism
in java. All these points makes java robust.

Compiled by Ms. K. Jayasri, CSE,


03/23/25 27
Aurora University
Architecture-neutral
Java is architecture neutral because there is no
implementation dependent features e.g. size of
primitive types is fixed.
In C programming, int data type occupies 2 bytes of
memory for 32-bit architecture and 4 bytes of memory
for 64-bit architecture. But in java, it occupies 4 bytes of
memory for both 32 and 64 bit architectures.

Portable
Java is portable because it facilitates you to carry the
java bytecode to any platform. It doesn't require any
type of implementation.

Compiled by Ms. K. Jayasri, CSE,


03/23/25 28
Aurora University
High-performance
Java is faster than other traditional interpreted programming
languages because Java bytecode is "close" to native code. It is
still a little bit slower than a compiled language (e.g. C++). Java is
an interpreted language that is why it is slower than compiled
languages e.g. C, C++ etc.

Compiled by Ms. K. Jayasri, CSE,


03/23/25 29
Aurora University
Compiled by Ms. K. Jayasri, CSE,
03/23/25 30
Aurora University
Java Architecture
Java Architecture is a collection of components,
i.e., JVM, JRE, and JDK. It integrates the process
of interpretation and compilation. It defines all the
processes involved in creating a Java
program. Java Architecture explains each and
every step of how a program is compiled and
executed.
•There is a process of compilation and
interpretation in Java.
•Java compiler converts the Java code into byte
code.
•After that, the JVM converts the byte code into
machine code.
•The machine code is then executed by the
machine.

Compiled by Ms. K. Jayasri, CSE,


03/23/25 31
Aurora University
Compiled by Ms. K. Jayasri, CSE,
03/23/25 32
Aurora University
Components of Java Architecture
The Java architecture includes the three main
components:
•Java Virtual Machine (JVM)
•Java Runtime Environment (JRE)
•Java Development Kit (JDK)
These are three main components of Java
Architecture. The execution of a program is done
with all these three components.

Compiled by Ms. K. Jayasri, CSE,


03/23/25 33
Aurora University
Java Virtual Machine
The main feature of Java is WORA. WORA
stands for Write Once Run Anywhere. The
feature states that we can write our code once
and use it anywhere or on any operating
system. Our Java program can run any of the
platforms only because of the Java Virtual
Machine. It is a Java platform component that
gives us an environment to execute java
programs. JVM's main task is to convert byte
code into machine code.
JVM, first of all, loads the code into memory and
verifies it. After that, it executes the code and
provides a runtime environment. Java Virtual
Machine
03/23/25 (JVM) has its
Compiled own
by Ms. K. Jayasri,architecture,
Aurora University
CSE, which
34
JVM Architecture
JVM is an abstract machine that provides the environment in which Java
bytecode is executed. The falling figure represents the architecture of the
JVM.

Compiled by Ms. K. Jayasri, CSE,


03/23/25 35
Aurora University
Java Runtime Environment
It provides an environment in which Java
programs are executed. JRE takes our Java
code, integrates it with the required libraries,
and then starts the JVM to execute it.

Java Development Kit


It is a software development environment
used in the development of Java applications
and applets. Java Development Kit holds JRE,
a compiler, an interpreter or loader, and
several development tools in it.
Compiled by Ms. K. Jayasri, CSE,
03/23/25 36
Aurora University
First Java Program

Compiled by Ms. K. Jayasri, CSE,


03/23/25 37
Aurora University
Class and Object Fundamentals
• • Class: Blueprint for objects.
• • Object: Instance of a class.

• Example:
• class Car {
• String color;
• void start() {
• System.out.println("Car is starting");
• }
• }

• public class Main {


• public static void main(String[] args) {
• Car myCar = new Car();
• myCar.color = "Red";
• myCar.start();
• }
• }
String Classes
• String class represents a sequence of
characters.
• Common Methods: length(), substring(),
concat(), equals()

• Example:
• String str = "Hello, World!";
• System.out.println(str.length());
• System.out.println(str.substring(0, 5));
•• • Constructor: Initializes a new object.
Constructors
• No return type, same name as class.

• class Person {
• String name;
• int age;
• Person(String name, int age) {
• this.name = name;
• this.age = age;
• }
• void display() {
• System.out.println(name + " is " + age + " years old.");
• }
• }

• public class Main {


• public static void main(String[] args) {
• Person p = new Person("Alice", 30);
• p.display();
• }
• }
This Keyword
• • 'this' keyword refers to the current object instance.
• • Used to differentiate between instance variables and parameters.

• Example:
• class Example {
• int value;
• Example(int value) {
• this.value = value;
• }
• void display() {
• System.out.println("Value: " + this.value);
• }
• }

• public class Main {


• public static void main(String[] args) {
• Example ex = new Example(10);
• ex.display();
• }
• }
finalize() Method
• 'finalize()' is called before an object is garbage collected.
• Allows cleanup before object is removed.

• Example:
class Demo {
@Override
protected void finalize() throws Throwable {
System.out.println("Object is being garbage collected");
}
public static void main(String[] args) {
Demo obj = new Demo();
obj = null;
System.gc();
}
}
Summary
• • Java Architecture: JVM, JRE, JDK
• • JVM Components: Class Loader, Bytecode
Verifier, Execution Engine, Garbage Collector
• • Core Concepts: Classes, Objects, Strings,
Constructors, 'this' keyword, finalize() method
Questions
• Thank you!
• Any questions?
Thank You!

You might also like