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

IntroToAdvancedProgramming_2025

The document outlines an Advanced Programming course focused on Java, covering topics such as object-oriented programming, GUI development, and exception handling. It includes course objectives, a detailed syllabus, grading criteria, and a brief history of Java technology. Additionally, it discusses the Java Runtime Environment, Java Development Kit, and provides examples of Java applications and applets.
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)
2 views

IntroToAdvancedProgramming_2025

The document outlines an Advanced Programming course focused on Java, covering topics such as object-oriented programming, GUI development, and exception handling. It includes course objectives, a detailed syllabus, grading criteria, and a brief history of Java technology. Additionally, it discusses the Java Runtime Environment, Java Development Kit, and provides examples of Java applications and applets.
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/ 28

ADVANCED PROGRAMMING (LTNC)

Instructor: Nguyen Thi Phuong Tram, PhD


Course ID: 214331- 4 credits
Theory: 45 hours
Practice: 30 hours
Course material modified by:
Email: [email protected]
17/02/2025 1
Mục tiêu
o Hiểu rõ và vận dụng được kiến thức cơ bản để giải
quyết các bài toán theo hướng đối tượng.

o Hiểu rõ và vận dụng các kiến thức về lập trình giao diện
để xây dựng các ứng dụng có tính thực tiễn cao.

Khoa CNTT – Trường ĐH Nông Lâm TP. HCM


Course Topics
◼ Chapter 1: General introduction to Java
◼ Chapter 2: Array and String in Java
◼ Chapter 3: Object Oriented Programming in Java
◼ Chapter 4: Inheritance, polymorphism
◼ Chapter 5: Abstract class and interface
◼ Chapter 6: Exception Handling
◼ Chapter 7: Generic Programming to Java
◼ Chapter 8: Building applications with Java
◼ Chapter 9: Programming Graphical User Interface
(GUI)
◼ Chapter 10: Building User-friendly Interfaces
with Java Swing
Khoa CNTT – Trường ĐH Nông Lâm TP. HCM
Bibliography
1. Liang, Y. D. (2019). Introduction to Java
programming and data structures: comprehensive
version. Pearson.
2. Paul Deitel, Harvey Deitel (2015). Java How to
Program, Early Objects-Pearson Education

Khoa CNTT – Trường ĐH Nông Lâm TP. HCM


Grading

◼ Attendance: 10%
◼ Exercise weekly: 10% (Lab)
◼ Midterm exam: 30% (Lab)
◼ Final exam: 50% (Lab)

Khoa CNTT – Trường ĐH Nông Lâm TP. HCM


A SHORT HISTORY OF JAVA
◼ The story of Java begins in June
1991, when a small team of
engineers at Sun Microsystems,
led by James Gosling, started a
project called Green.
◼ The goal of the project was to
develop a programming
language for consumer electronic
devices, such as smart TVs, set-
top boxes, and handheld
controllers
◼ James Gosling and his team….
called as “OAK”…
Khoa CNTT – Trường ĐH Nông Lâm TP. HCM
A SHORT HISTORY OF JAVA
◼ Sun released the first version of Java in early 1996.
People quickly realized that Java 1.0 was not going to cut
it for serious application development.
◼ The big news of the 1998 Java One conference was the
upcoming release of Java 1.2, which replaced the early
toy-like GUI and graphics toolkits with sophisticated and
scalable versions that come a lot closer to the promise of
"Write Once, Run Anywhere" than their predecessors.
◼ Besides the "Standard Edition," two other editions were
introduced: the "Micro Edition" for embedded devices
such as cell phones, and the "Enterprise Edition" for
server-side processing.

Khoa CNTT – Trường ĐH Nông Lâm TP. HCM


ABOUT THE JAVA TECHNOLOGY
◼ Java technology is a programming language and a platform
◼ The Java programming language is a high-level language that
can be characterized by all of the following buzzwords:

Khoa CNTT – Trường ĐH Nông Lâm TP. HCM


ABOUT THE JAVA TECHNOLOGY
1. Simple → Đơn giản
2. Object Oriented → Hướng đối tượng

3. Platform Independent → Độc lập nền tảng

4. Secured → Bảo mật

5. Robust → Mạnh mẽ(Java có hệ thống thư viện lớn;Ràng buộc

người lập trình chặt chẽ)


6. Architecture-neutral → Kiến trúc - tập trung

7. Portable → Khả chuyển Write Once, Run Anywhere”

8. Dynamic → Java được thiết kế như một ngôn ngữ động để đáp

ứng cho những môi trường mở


9. Interpreted →Thông dịch

10. High Performance → Hiệu suất cao (Just – In – Time)

11. Multi-thread → Đa luồng


12. Distributed → Phân tán

Khoa CNTT – Trường ĐH Nông Lâm TP. HCM


ABOUT THE JAVA TECHNOLOGY
◼ In the Java programming language, all source code is first
written in plain text files ending with the .java extension.
Those source files are then compiled into .class files by
the Java compiler (javac). A .class file does not contain
code that is native to your processor; it instead contains
bytecodes-- the machine language of the Java Virtual
Machine. The Java launcher tool (java) then runs your
application with an instance of the Java Virtual Machine.

Khoa CNTT – Trường ĐH Nông Lâm TP. HCM


ABOUT THE JAVA TECHNOLOGY

Khoa CNTT – Trường ĐH Nông Lâm TP. HCM


The Java Runtime Environment
◼ The Java application environment performs as
follows:

17/02/2025 12
Khoa CNTT – ĐH Nông Lâm TP. HCM 01/2016 12/48
JVM Tasks
◼ The JVM performs three main tasks:
– Loads code – Performed by the class loader.
• Loads all classes necessary for the execution of a
program
• Avoids execution of the program whose bytecode has
been changed illegally.
– Verifies code – Performed by the bytecode verifier.
• The code adheres to the JVM specification.
• The code does not violate system integrity.
• The code causes no operand stack overflows or
underflows
• The parameter types for all operational code are correct.
• No illegal data conversions have occurred.
– Executes code – Performed by the runtime interpreter.
Khoa CNTT – Trường ĐH Nông Lâm TP. HCM
Java Technology Runtime Environment

Khoa CNTT – Trường ĐH Nông Lâm TP. HCM


JDK – Java Development Kit
◼ Free development and run-time environment provided
by Sun Microsystems (http://java.sun.com)
◼ Most widely used Java software development kit
◼ Main components:
– javac compiler, converts source code into Java
bytecode
– java interpreter and application loader
– appletviewer interpreter, run and debug Java applets
without a web browser
– javadoc documentation generator, automatically
generates documentation from source code comments
– jdb debugger
– javap class file disassembler
Khoa CNTT – Trường ĐH Nông Lâm TP. HCM
Types of Java applications
◼ Desktop application – Java SE (Java Standard Edition)
– Java Application: normal Java application running on
desktops; console or GUI
– Java Applet: embedded application running within Web
browsers
◼ Server application – Java EE (Java Enterprise Edition)
– JSP và Servlet, JSF, EJB
◼ Mobile (embedded) application – Java ME (Java Micro
Edition)
◼ Java Card

Khoa CNTT – Trường ĐH Nông Lâm TP. HCM


Java Desktop Applications
◼ Complete application programs
◼ Console or GUI
◼ Launched by java command

Khoa CNTT – Trường ĐH Nông Lâm TP. HCM


A Sample Java program

TestGreeting.java same name with class

Declare new class commented line


main method from
where the program
// This is a simple program begins its execution
public class TestGreeting {
public static void main(String[] args) {
System.out.println("Hello, world");
}
}

object message displays the string Hello, world on


the screen

Khoa CNTT – ĐH Nông Lâm TP. HCM 01/2016 18/48


Compiling & executing the program
◼ The java compiler creates a file called
TestGreeting.class that contains the byte codes

◼ To actually run the program, a java interpreter called


java is required to execute the code.

Khoa CNTT – ĐH Nông Lâm TP. HCM 01/2016 19/48


Passing Command Line Arguments
class CommLineArg {
public static void main (String[] pargs) {
System.out.println("These are the arguments passed
to the main method.");
System.out.println(pargs[0]);
System.out.println(pargs[1]);
System.out.println(pargs[2]);
}
}

Output

Khoa CNTT – ĐH Nông Lâm TP. HCM 01/2016 20/48


Small improvement
◼ Two classes in separated files
TestGreeting.java

public class TestGreeting {


public static void main(String[] args) {
Greeting gr = new Greeting();
gr.greet();
}
}
Greeting.java
public class Greeting {
public void greet() {
System.out.print("Hello, world");
}
}

Khoa CNTT – Trường ĐH Nông Lâm TP. HCM


Compile and run
◼ Compile TestGreeting.java
◼ javac TestGreeting.java
◼ Greeting.java is automatically compiled
◼ Run
◼ java TestGreeting
◼ Result
◼ Hello, world

Khoa CNTT – Trường ĐH Nông Lâm TP. HCM


Java Applets
◼ Embedded into webpages, i.e. run in web browsers.
◼ Or in appletviewer
◼ Limited graphical interface
◼ No access to client’s resources
◼ can do no evil

Khoa CNTT – Trường ĐH Nông Lâm TP. HCM


A simple applet

Welcome.java
// Java packages
import java.awt.Graphics;
import java.applet.Applet;

public class Welcome extends Applet {


public void paint(Graphics g) {

// call superclass version of method paint


super.paint(g);

// draw a String
g.drawString("Welcome to Java programming!", 25, 25);
}
}

Khoa CNTT – ĐH Nông Lâm TP. HCM 01/2016 24/48


Embedded into a Webpage

Welcome.html:
<html>
<applet code = "Welcome.class" width = "300" height = "45">
</applet>
</html>

Khoa CNTT – ĐH Nông Lâm TP. HCM 01/2016 25/48


Running
• in web browser

• In applet viewer: appletviewer Welcome.html

Khoa CNTT – ĐH Nông Lâm TP. HCM 01/2016 26/48


Integrated Development Environment - IDE
◼ Provides comprehensive facilities to computer
programmers for software development.
◼ Normally consists of a source code editor, build
automation tools and a debugger.
◼ IDEs can contain compiler, interpreter.
◼ Some Java IDEs:
◼ Eclipse
◼ Netbean

Khoa CNTT – Trường ĐH Nông Lâm TP. HCM


Q&A

Khoa CNTT – Trường ĐH Nông Lâm TP. HCM

You might also like