2 Computer Programming Module 2
2 Computer Programming Module 2
Pre-test: True or False – Write True if the said statement is true, and write False if the statement is false, on a
one-half cross-wised sheet of yellow pad paper.
1. A class is an object constructor, or a “blueprint” for creating objects. It can be private or public.
2. Data type is a block of code which runs when it is called. Methods are used to perform certain
actions, and they are also known as functions.
3. Variable is a piece of memory that can contain a data value. A variable thus has a data type.
Variables are typically used to store information which your java program needs to do its job.
4. A compiler is a program that converts instructions into a machine-code or lower-level form so that
they can be read and executed by a computer.
5. The Java API or built-in package is a library of prewritten classes that are free to use.
6. Data types specify the different sizes and values that can be stored in the variable.
7. The comments can be used to provide information or explanation about the variable, method, class
or any statement.
8. I/O is an essential concept while working on Java programming.
9. JCreator is an example of a compiler.
10. Java is a class-based, object-oriented programming language developed by James Gosling.
MODULE 2 – BASIC PROGRAMMING LANGUAGE CODES
Now, if you are curious what’s inside a Java program, let me introduce you this:
So what are these parts of the source code or program that I specified?
Built-in Packages – the Java API is a library of prewritten classes that are free to use.
User-defined packages – to create your own package, you need to understand that
Java uses a file system directory to store them.
Example: packagemypack;
Explanation: To better understood what is a package, let’s use the example of a Balikbayan
box, full of candies, chocolates, clothes, etc. A certain package should be sent to
the receiver in order for that receiver to use the contents of the box.
2. Class – a class is an object constructor, or a “blueprint” for creating objects. It can be private or
public.
Explanation: To better understood what is a class, let’s use the example of an anime drawing,
you cannot draw directly the character without using a blueprint or a guide. Same
goes to classes, you cannot proceed in what you want to code if there’s no class in
it.
MODULE 2 – BASIC PROGRAMMING LANGUAGE CODES
3. Method – is a block of code which runs when it is called. Methods are used to perform certain
actions, and they are also known as functions.
Explanation: To better understood what is a class, let’s use the example of an anime drawing,
you cannot draw directly the character without using a blueprint or a guide. Same
goes to classes, you cannot proceed in what you want to code if there’s no class in
it.
4. Data types – data types specify the different sizes and values that can be stored in the variable.
Primitive data types – this include boolean, char, byte, short, int, long, float and
double.
Non-primitive data types – the non-primitive data types include classes, interfaces
and arrays.
5. Variable – is a piece of memory that can contain a data value. A variable thus has a data type.
Variables are typically used to store information which your java program needs to do its job.
Explanation: To better understood what are data types and variables, let’s use the example of a
glass container full of salt. The data type is the container, and the variable is the
salt inside the container.
6. Comments – are the statements that are not executed by the compiler and interpreter. The comments
can be used to provide information or explanation about the variable, method, class or any statement.
Comments are usually starts with either “/”, “//” or “/* */”.
7. Input and output –is an essential concept while working on Java programming. It consists of
elements such as input, output and stream.
Teacher’s trivia!
Against all odds, DO NOT forget to end your code line with a semicolon (;), or you will face the
consequences.
1.1 – Compilers
In creating a source code, of course, we need to have a compiler to compile our source code created.
Explanation: To understand further a compiler, let’s use the concept of folded clothes in your
cabinet. Notice that your cabinet has full of clothes, and were being placed in a
cabinet, segregated. So, a compiler is like a cabinet, and the source code is like
the folded clothes.
MODULE 2 – BASIC PROGRAMMING LANGUAGE CODES
1. Eclipse
2. JCreator
3. DCoder (for mobile coding)
4. Turbo C++
5. Microsoft Visual Studio
Before you proceed to this part, you must download DCoder first and then follow the instructions
below on how to open DCoder and start coding using Java programming language.
class HelloWorld{
public static void main (String [] args){
System.out.println(“Hello World”);
}
}
After you code this one, what have you noticed in the output part? Is the Hello world! output popped up?
If so, then you’re good to go for the next activity.
Evaluation: True or False – Write True if the said statement is true, and write False if the statement is false,
on a one-half cross-wised sheet of yellow pad paper.
1. A class is an object constructor, or a “blueprint” for creating objects. It can be private or public.
2. Data type is a block of code which runs when it is called. Methods are used to perform certain
actions, and they are also known as functions.
3. Variable is a piece of memory that can contain a data value. A variable thus has a data type.
Variables are typically used to store information which your java program needs to do its job.
4. A compiler is a program that converts instructions into a machine-code or lower-level form so that
they can be read and executed by a computer.
5. The Java API or built-in package is a library of prewritten classes that are free to use.
6. Data types specify the different sizes and values that can be stored in the variable.
7. The comments can be used to provide information or explanation about the variable, method, class
or any statement.
8. I/O is an essential concept while working on Java programming.
9. JCreator is an example of a compiler.
10. Java is a class-based, object-oriented programming language developed by James Gosling.
Essay: For ten points, write what have you learned about this weekly topic that we have on this interactive
module.
Some Notes:
1. Post-test will be recorded and the instructor will collect your answers.
2. Activities will also be recorded and the instructor will collect your exercises.
Bibliography/References:
https://www.onlinecollegeplan.com/computer-programming-languages