answer. Place your answer after each item. Refer to reference below. 1. Java Introduction
o 1.1 Java Hello World- It is used to introduce a new programming
language to a newbie. And in this program Hello world is the class name which each class must be match in the filename of java language for it to be able to work. To start a java compiler on executing, all java program must contain a main method which is the; public static void main(String[] args) { ... }. And lastly a code to print a statement are; System.out.println("Hello, World!"); to print out the text HellO World. o 1.2 Java JVM, JRE and JDK- JVM- Java Virtual Machine is an abstract machine for the computer to run a java program. With the help of JVM the java compiler will compile first the java code into bytecode then JVM will translate the bytecode into a machine code which a set of instructions for a computer to executes it directly. JRE- Java Runtime Environment is a software that provides class libraries. It is required to run java applications such JVM and other components. JDK- Java Development Kit is always with JRE and both of it contains compilers, JavaDoc, Java Debugger, and others. This software is to develop an applications in java. o 1.3 Java Variables and Literals Java Variables is a location memory to hold a data. Each variable must be unique because it is the identifier in a program. Any name of a variable is possible; age, gender, speed limit, color and etc. Java literals are data that is used in representing fixed values; int =5; float = 3.4 char = ‘G’ ; o 1.4 Java Data Types- Specifying the types of data in java is very important because it will be stored inside variable in java. And we need to keep in mind that this kind of programming language is a statically typed language where all variables must be declared first for us to be able to use it. For example; Age is a variable then this kind of data must only contain int (Integers). There are 8 Primitive data types; Boolean, byte, short, int, long double, float, and char. o 1.5 Java Operators- contains symbols that perform operations on a variable and values. Java operators are classified into 5 types; Arithmetic ( +, -, *, /, %) , Assignment (=, +=, -=, *=, /=, %=), Relational ( ==, !=, >, <, >=, <=), Logical ( &&, ||, !), Unary ( +, -, ++, --, !), and Bitwise ( ~, <<, >>, >>>, &, ^) . o 1.6 Java Input and Output- The input in java is the data that we give or we encode in the program while the output is what we receive from the program. For example we encode the source code of hello world then the output will be Hello, World! o 1.7 Java Expressions & Blocks Java Expressions- are consists of variables operators literals and other methods. For example score = 21. Java blocks- is a group of statements that is enclosed by curly braces. Where A block begins with an opening brace ({) and ends with a closing brace (}). For example: { int e = 100; j = 280; } o 1.8 Java Comment- a portion of the program that is mainly used to help programmers to understand the code. The java comment is completely ignored by java compilers.
2. Java Flow Control
o 2.1 Java if...else- If statement is used to only execute code when a
condition is true while the else statement executes when the condition in if statement is false. For example; int time= 20 ; if ( time < 18 ) System.print.out.printIn(“Good day. ”) ; else System.print.out.printIn(“Good Evening. ”) ; o 2.2 Java switch Statement- allows us to execute a block of code among many alternatives. o 2.3 Java for Loop- is an entry-controlled loop that facilitates a user to execute a block of a statements iteratively for a fixed number of times. o 2.4 Java for-each Loop- a flow control that provides an alternative approach to traverse the array or collection in Java. o 2.5 Java while Loop- a control flow statement that allows code to be executed repeatedly based on a given Boolean condition. o 2.6 Java break Statement- breaks the current flow of the program at specified condition. o 2.7 Java continue Statement- stops one iteration in a loop and continues to the next iteration