[go: up one dir, main page]

0% found this document useful (0 votes)
202 views28 pages

CC102 Week-4 Lesson-Introduction To Java Programming

The document provides an introduction to Java programming including: - A brief history of Java and why it was named Java - An overview of Java features like being object-oriented, platform independent, robust, and high-performance - The differences between Java applets and applications - The basic structure of a Java program including classes, methods, and the main method - How to set up the Java development environment - The process of compiling and running a Java program - Tips on naming conventions and organizing Java files

Uploaded by

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

CC102 Week-4 Lesson-Introduction To Java Programming

The document provides an introduction to Java programming including: - A brief history of Java and why it was named Java - An overview of Java features like being object-oriented, platform independent, robust, and high-performance - The differences between Java applets and applications - The basic structure of a Java program including classes, methods, and the main method - How to set up the Java development environment - The process of compiling and running a Java program - Tips on naming conventions and organizing Java files

Uploaded by

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

WEEK 4

INTRODUCTION TO JAVA
PROGRAMMING
CC102 – PROGRAMMING 1
• Describe and discuss Java Story, technology,
features, and requirements;
• Differentiate Applet and Application.

2
What is Java?
• was created in 1991
• by James Gosling ,
Mike Sheridan
Patrick Naughton
of Sun Microsystems.
• First, it was called “Greentalk” and the file extension was .gt
• After that it was called Oak, and was developed as part of the Green Project
• its name was changed to Java because there was already a language called
Oak
3
Why Java Programming named "Java"?
• According to James Gosling, "Java was one of the top choices along with Silk".
• Java was so unique, most of the team members preferred Java than other
names.
• Java is an island of Indonesia where first coffee was produced (called java
coffee).
• In 1995, Time magazine called Java one of the Ten Best Products of 1995.
• JDK 1.0 released in(January 23, 1996).

4
Java Version History
• JDK Alpha and Beta (1995) • Java SE 6 (11th Dec 2006)
• JDK 1.0 (23rd Jan 1996) • Java SE 7 (28th July 2011)
• JDK 1.1 (19th Feb 1997) • Java SE 8 (18th March
• J2SE 1.2 (8th Dec 1998) 2014)

• J2SE 1.3 (8th May 2000) • Java SE 9 (21st Sep 2017)


• JJ2SE 1.4 (6th Feb 2002) • Java SE 10 (20th March
• J2SE 5.0 (30th Sep 2004) 2018)

5
The first projects developed using Java
• A personal hand-held
remote control named:
• Star 7
• was part of the: Green Project

6
What is Java Technology?
The Java technology is:
- A programming language
- A Development Environment
- An application environment
- An Deployment environment

7
8
Java Features
1. Object-oriented
Basic concepts of OOPs are:
• Object
• Class
• Inheritance
• Polymorphism
• Abstraction
• Encapsulation
9
Java Features
2. Simple 5. Robust
3. Secured 6. Portable
4. Platform Independent 7. Architecture-neutral
• Two types of
platforms:
1. software-based
and;
2. hardware-based.
10
Java Features
8. Dynamic
9. Interpreted
10. High-performance
11. Multi-threaded
12. Distributed
13. High-performance
14. Multi-threaded
15. Distributed
11
Java Development Environment
• Installing JDK (Java Development Kit) produces several
folders in your system.
• Each of these folders holds pertinent files that would be
necessary in building your program.
• For instance, the bin folder contains executable files for
compiling your program (javac.exe).
12
Java Development Environment

13
Java Program Cycle
• Use any text editor to create source code — .java file
• Source code compiled according to JVM to get byte code
— .class file
• Byte code executed using an interpreter
Source
Codes Compiler Byte Interpreter Output

14
Java Program Cycle
Class HelloQCU {
Public static void main (String [ ] args)
{
System.out.println(“Hello QCU!”);
}
}

Hello QCU!

Class HelloQCU {
Public static void main (String [ ] args) {
System.out.println(“Hello QCU!”);
}
}

15
Java can be used to create two types of programs:

• Applet
special applications designed to run within the context of a
Web browser.
• Application
stand-alone program that does not need a browser to run.

16
Applet Application
17
Java Program Structure
• In the Java programming language:
 A program is made up of one or more classes
 A class contains one or more methods
 A method contains program statements

• A Java application always contains a method called main


18
The main() method
• When executing a Java application, the JVM loads the class, and
invokes the main() method of this class.

• The method main() must be declared public, static, and void.

• A source file may have one or more classes.

• Only one class (matching the file name) at most may be declared
public.
19
Organizing Your Java Application
• A Java application is composed of a set of files generally distributed in a
directory structure
1. Source code: filename.java
2. Class file: classname.class (the same w/ filename)
• The compiler searches for a class file when it
encounters a reference to a class in a .java file
• The interpreter, during runtime, searches the .class files
• Both the compiler and the interpreter search for the .class files in the list of
directories listed in the classpath variable.
20
A sample source code in java

21
Tips: Names

22
Tips: Names

• The qualified name for the class is course.Student, and the path name to it is
course/Student.java
• to import the package:
import course.Student;
• You can import all the classes in the package:
import course.*;

23
Tips: Names Advantages
• It makes it easier to find and use classes.
• It avoids naming conflicts. Two classes with the
same name existing in two different packages
do not have a name conflict, as long as they
are referenced by their fully qualified name.
• It provides access control.

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

25
Compilation Flow:

26
References:
• TutorialsPoint.,( 2019). Learn Java Programming Retrieved
from: https://www.tutorialspoint.com/java.
• JavaTPoint., (2019). Java Tutorial. Retrieved from:
https://www.javatpoint.com/java-tutorial

27
28

You might also like