Java Reviewer
Java Reviewer
Just like every other process, programming also follows a cycle –PDLC or program
development life cycle.
Usually, the cycle consists of the phases illustrated at the right.
1. Analyze the Problem
2. Design the Program
3. Coding and Execution
4. Testing and Debugging
5. Formalize the Solution
6. Documentation
2. Organizing requirements – The requirements are arranged in order of importance, urgency and
convenience
3. Negotiation & discussion - If there are confusing or vague requirements, a negotiation is conducted
and discussed with the stakeholders.
There are two ways of doing this, either compile the program or interpret the program. The process of
compiling and interpreting a program can be accomplished by using other programs called compilers
and interpreters, these programs translate the program written in high-level language into machine
Two types of Programming Paradigm
1. Structured Programming
known as procedural programming that uses the principles of Top- Down Design Principle was first
created by Dr. Edsger W. Dijktstra in 1960s. It uses the following control structures:
b. Selection / Condition-one or a number of statements are executed depending on the state of the
program. This is usually expressed with keywords such as if-then-else and switch case statements.
c. Iteration / Loops- A statement or block is executed until the program reaches a certain state,
oroperations have been applied to every element of a collection.
Example of structure programming language as COBOL, ALGOL FORTRAN, SNOBOL, LOGO, Pascal,
BASIC, Modula-2, C, Perl, PL/I.
A programming paradigm based on the concept of "objects", which are data structures that contain data,
in the form of fields, often known as attributes;
This object-oriented programming concept was first introduced in the 1960's in a programming language
called Simula 67 that is created by Ole- Johan Dahl and Kristen Nygaard at the Norwegian Computing
Center in Oslo, Norway.
a. Object - A concept, or thing with crisp boundaries and meanings for the problem at hand: an
instance of a class
b. Class-An abstraction of an object that specifies the static and behavioral characteristics of it,
including their public and private nature. A class is an ADT with a constructor template from
which object instances are created.
c. Inheritance-The relationship between classes whereby one class inherits part all of the public
descriptions of another base class, and instances inherit all the properties and methods of the
classes which they contain
d. Polymorphism-The ability of a function/operator, with one name, to refer to arguments, or
return types, of different classes at run time.
e. Abstraction- A mental facility that permits one to view problems with varying degrees of
detail depending on the current context of the problem.
f. Encapsulation - A modeling and implementation technique that separates the external aspects
of an object from the internal, implementation details of the object.
Brief History of Java
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 the time. The language was initially called Oak after an oak
tree that stood outside Gosling's office. Later the project went by the name Green and was
finally renamed Java, from Java coffee. Gosling designed Java with a C/C++ style syntax that
system and application programmers would find familiar. Sun Microsystems released the first
public implementation as Java 1.0 in 1995. It promised "WriteOnce, Run Anywhere" (WORA),
Characteristics of Java
Java is simple.
Java is object-oriented.
Java is distributed.
Java is interpreted.
Java is robust.
Java is secure.
Java is architecture-neutral.
Java is portable.
Java's performance.
Java is multithreaded.
Java is dynamic.
Java Syntax of the Java programming language is the set of rules defining how a Java program is written
and interpreted.
• Now that the requirements have been identified, the next phase is designing the program.
• “Debugging” actually means finding and removing “bugs” or errors for the program to function
properly and meet its requirements.
Documentation
• In this phase, the programmers write down instructions for the end users (the ones who are going to
use the system), the purpose of the program, how it performs its functions, the input needed and the
output expected.
• Internal documentations are done by programmers through comments (this will be discussed in a later
module).
Algorithm
• Algorithm is used to describe how you do simple daily tasks or actions.
• In computer science, algorithm is defined as a procedure or formula which consists of a set of steps to
accomplish a specific task.
Flowchart
• A flowchart is a graphical representation of an algorithm using shapes and symbols to illustrate the
steps or procedure.
2. Flow lines enter from the top of the symbol and exits at the bottom of the symbol; except for the
decision which can be connected by the flow lines at the bottom or side.
3. Flowcharts are drawn in a way that it logically flows from top to bottom.
Documentation Standards
• An effective programmer does not only write codes and programs that work without errors and bugs.
• You also have to follow coding techniques, programming practices and documentation protocols in
case new features will be added to the program: change its features, fix bugs and improve performance.
• Your codes should be readable enough so that other programmers can comprehend them very well.
2. Quick Launch Bar / Toolbar – the most commonly used actions are displayed in this toolbar
3. Projects Windows – this is where you will see the project files, classes and other Java files. Click the +
or – sign beside each folder to collapse or expand the list.
4. Navigator – this feature allows Java programmers to be oriented in source code and conduct basic
actions.
6. Assist Icons – icons that allow you to add comments and bookmarks, find selected text or code and
change indentation of codes.
7. Line Number – this tells you the line number of each line of code
Syntax
• You’ve probably seen this word when you typed something wrong on your calculator “Syntax Error”.
• Basically, syntax is one of the building blocks of programming language – it is the spelling and grammar
of programming.
JAVA COMMENTS
Comments can be used to explain Java code, and to make it more readable. It can also be used to
prevent execution when testing alternative code.
Single-line comments start with two forward slashes (//). Any text between // and the end of the line is
ignored by Java (will not be executed).
Multi-line comments start with /* and ends with */. Any text between /* and */ will be ignored by Java.
JAVA VARIABLES
Variables are containers for storing data values. In Java, there are different data types
String - stores text, such as "Hello". String values are surrounded by double quotes
int - stores integers (whole numbers), without decimals, such as 123 or -123
float - stores floating point numbers, with decimals, such as 19.99 or -19.99
char - stores single characters, such as'a' or 'B'. Char values are surrounded by single quotes
• Primitive data types -includes byte, short, int, long, float, double, boolean and char
Variables are used to store up temporary data to be used in our programs’ runtime.
Data Type – The type of data inside variable.
Identifiers– It is the name of the variable that the programmer indicated. It is used to read and write
the variable.
Rules of identifiers
Conditional Statements
• Allows a program to take action based on the given condition. It makes our program smarter.
• Typically it compares two values so that our program can decide what action to be taken.
Relational Operators
- How are we compare our value to in value to activate our condition
Conditional Statements
Typically it compares two values so that our program can decide what action to be taken.
when our value is greater than equal 18 the condition print out "You Have Access"
IF – Else Statement -Handles 2 conditional expressions, it either does the first code block or the second
code block.
}else{System.out.println("Access Denied");}
This is example of IF Else statement when our value is greater than equal 18 the condition print out
"You Have Access”
if the value dint get through the else will catch the condition and print out "Access Denied"
-Handles 3 or more Conditional Expressions, The possibility of this statements are limitless it will run a
certain code block based on the condition.
}else{System.out.println("Access Denied");}
This just same as the other they just add ELSE IF its just like if they use ELSE IF there going to be
another condition and ELSE IF you can use it unlimited
Importing Packages
Import specific class
User Input
String x; (you need to make a datatype that don’t have value or null)
Scanner s = new Scanner(System.in); (you need to set first a Scanner base the s is your variable)
x=s.nextLine(); (x is your variable in String and =s.nextLine)