Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

Palawan State University

MODULE 1 Bachelor of Science in Information Technology


Quezon Campus
COMPUTER PROGRAMMING 1

Page | 1 Prepared by Ms. Heraine Jane D. Cortado


Palawan State University
MODULE 1 Bachelor of Science in Information Technology
Quezon Campus
COMPUTER PROGRAMMING 1

4 Chapter
INTRODUCTION TO JAVA PROGRAMMING LANGUAGES

JAVA BACKGROUND

Java programming language is one of the most popular and widely used programming languages,
both in education and in industry, it was first written and developed by Dr. James Gosling and his
colleagues in early 1990’s at Sun Microsystem, which is now part of Oracle Corporation after acquisition
was complete on January 27, 2010. Java was released in 1995 as part of Sun Microsystem’s Java platform.

James Gosling, Mike Sheridan, and Patrick Naughton initiated the Java language project in
June 1991. Java was originally designed for interactive Television, but it was too advanced for the digital
cable television industry at that time. The language was initially called Oak after an oak tree that stood
outside the Gosling’s Office. Later the project went by the name Green and was finally renamed Java, from
Java coffee. Gosling designed Java with C/C++ style syntax that system and application programmers
would find it familiar.

• Java 1.0 in 1995 promised “Write Once, Run Anywhere” (WORA).


• Java 1.0 Compiler written by Arthur Van Hoff.
• November 13, 2006, java was released as free and open source software.
• Java software runs on everything from laptops to data centers, game consoles to scientific
supercomputers.
• April 02, 2010, James Gosling resigned from Oracle.

Watch the Video


Video # 9 : Java Applications

Watch the Video


Video # 10 : Characteristics of Java

Watch the Video


Video # 11 : Benefits of Java

Watch the Video


Video # 12 : Features of Java Language

Watch the Video


Video # 13 : Inventors of Programming Languages

Page | 2 Prepared by Ms. Heraine Jane D. Cortado


Palawan State University
MODULE 1 Bachelor of Science in Information Technology
Quezon Campus
COMPUTER PROGRAMMING 1

DISSECTING MY FIRST JAVA PROGRAM

Now, we'll try to dissect your first Java program:

public class BSIT


{
/*** My first java program */
public static void main(String[] args) {

//prints the string "Hello world" on screen


System.out.println("Welcome!");

}
}

The first line of the code,


public class BSIT

indicates the name of the class which is BSIT. In Java, all code should be placed inside a class declaration.
We do this by using the class keyword. In addition, the class uses an access specifier public, which
indicates that our class in accessible to other classes from other packages (packages are a collection of
classes). We will be covering packages and access specifiers later.

The next line which contains a curly brace { indicates the start of a block. In this code, we placed the curly
brace at the next line after the class declaration, however, we can also place this next to the first line of our
code. So, we could actually write our code as:

public class BSIT


{
or
public class BSIT {

The next three lines indicates a Java comment. A comment is something used to document a part of a
code. It is not part of the program itself, but used for documentation purposes. It is good programming
practice to add comments to your code.

/** * My first java program */

A comment is indicated by the delimiters “/*” and “*/”. Anything within these delimiters are ignored by the
Java compiler, and are treated as comments.
The next line,
public static void main(String[] args)
{

or can also be written as,

public static void main(String[] args) {

Indicates the name of one method in BSIT which is the main method. The main method is the starting point
of a Java program. All programs except Applets written in Java start with the main method. Make sure to
follow the exact signature.

The next line is also a Java comment,

//prints the string "Welcome" on screen

Now, we learned two ways of creating comments. The first one is by placing the comment inside /* and */,
and the other one is by writing // at the start of the comment.

Page | 3 Prepared by Ms. Heraine Jane D. Cortado


Palawan State University
MODULE 1 Bachelor of Science in Information Technology
Quezon Campus
COMPUTER PROGRAMMING 1

The next line,

System.out.println("Welcome!");

Prints the text “Welcome!” on screen. The command System.out.println(), prints the text enclosed by
quotation on the screen.

The last two lines which contains the two curly braces is used to close the main method and class
respectively.

Coding Guidelines:

1. Your Java programs should always end with the .java extension.

2. Filenames should match the name of your public class. So for example, if the name of your public
class is Hello, you should save it in a file called Hello.java.

3. You should write comments in your code explaining what a certain class does, or what a certain
method do.

The program looks like this:

public class BSIT


{

public static void main(String[] args) {

System.out.println("Welcome!");

}
}

The Output is:

Welcome!

Page | 4 Prepared by Ms. Heraine Jane D. Cortado

You might also like