Elective 11 - Lesson 1 & 2
Elective 11 - Lesson 1 & 2
DEMONSTRATING KNOWLEDGE OF
JAVA TECHNOLOGY AND JAVA
PROGRAMMING
JAVA BASICS
JAVA
• is a general purpose computer programming language
that is concurrent, class based, object oriented and
designed to have as few implementation dependencies as
possible.
HISTORY OF JAVA
• James Gosling is the founder or the first person who
initiated Java language project in June 1991.
• The language, initially called ‘Oak’ after an oak tree that
stood outside Gosling's office.
• Then released as Java from Java coffee, which is why the
logo for Java is of a steaming coffee cup.
FEATURES OF JAVA
A. OBJECT-ORIENTED - Java was not intended to be source-code attuned with
any other language. Because of this , Java has a tidy , functional , and logical
approach to objects. It has been said that Java is simple and easy to extend object
model. Primitive types are set aside as high –performance non objects.
B. DYNAMIC – To prove access to objects at run time, Java programs bring large
amounts of run-time type information that makes it probable to dynamically link
code safely.
C. MULTITHREADED – Java multithreaded programming allows users to create
programs that perform many executions instantaneously.
D. ARCHITECTURE-NEUTRAL – code longevity and portability was the main
problem of Java programmers during the time of its creation.
JAVA DEVELOPMENT
ENVIRONMENT
• Java programs undergo five phases: create/edit, compile, load, verify, and
execute.
Phase 1. This is where the programmer types the needed rectifications and
save the program on a storage device as .java file extension.
Javac Greeting.java
Phase 3. Before loading is performed, the programmer will have to place the
program in the memory before it can implement a process.
Phase 4. Bytecodes are examined by the bytecode verifier to validate that it does
not defy java restrictions. It ensures that java programs entering over the network
does not harm the user’s file or system.
Phase 5. The bytecode stated in the program will be executed by the JVM. As
they are interpreted. JVM analyzes the bytecodes.
LESSON 2
CREATING EXECUTABLE
JAVA APPLICATIONS
PROGRAM IN JAVA
JAVA APPLICATION – is a program that performs when you use the Java command to run the
Java Virtual Machine (JVM).
Where:
Line 1 – begins with // indicate comment lines. This is where the user can insert
documentation used to improve readability. /* */, this is a traditional comment. It can be
split over multiple lines.
Line 2 – blank lines can be used so that programs are easier to read.
Line 3 – this is the class declaration for class Welcome.java programs must have at least
one class declaration that is defined.
Line 4 – a left brace indicates the beginning of the body of a class declaration.
Line 5 – this shows the starting point of a Java application. Items enclosed in parenthesis
indicates that it is a program building block called method.
Where: (cont.)
Line 6 – this left brace starts the body of the method.
Line 7 – this directs the computer to do an action.
Line 8 – this right brace end each class declaration.
Line 9 – this right brace must end the method declaration’s body.
• The System.out object is known as the standard output object. It
allows Java applications to display strings in the command
window from which the Java application executes.