Presented By: Anjali Prasad Guided By: Mrs - Prajakta Mam
Presented By: Anjali Prasad Guided By: Mrs - Prajakta Mam
PRESENTED BY:
GUIDED BY:
ANJALI PRASAD
Mrs.PRAJAKTA MAM
JAVA PROGRAM DEVELOPMENT
●Java program normally go through five phases. These are
●1.Edit
●2.Compile
●3.Load
●4.Verify and
●5.Execute
●We look over all the above mentioned phases in a bit detail.
●Phase 1(EDIT): consists of editing a file. This is accomplished with an
editor program. The programmer types a java program using the editor
like notepad, and make corrections if necessary.Java program file name
ends with a .java extension.
●Phase 2(COMPILE): the programmer gives the command javac to compile
the program. The java compiler translates the java program into bytecodes,
which is the language understood by the java interpreter. To compile a program
called Welcome.java, typejavac Welcome.javaat the command window of
your system. If the program compiles correctly, a file called
Welcome.class is produced.
●Phase 3(LOADING): the program must first be placed in memory before it
can be executed. This is done by the class loader, which takes the .class
file (or files) containing the bytecodes and transfers it to memory.
●Phase 4(VERIFY):VerifyBefore the bytecodes in an application are
executed by the java interpreter, they are verified by the bytecode
verifier.This ensures that the bytecodes for class that are loaded form the
internet are valid and that they do not violate Java’s security restrictions.
●Phase 5(EXECUTE): Execute finally in this phase , the computer, under
the control of its CPU, interprets the program one bytecode at a time.
Thus performing the actions specified by the program.Programs may not
work on the first try.
DATA TYPES IN JAVA
●A data type is an attribute of a variable which tells the compiler
or interpreter how the programmer intends to use the variable.
●According to the properties they possess, data types are divided
into two groups:
● Primitive Data Types
● Non-Primitive Data Types
PRIMITIVE DATA TYPE
●Primitive data types in Java are classified into 4 aspects as int, float,
character and boolean. But, in general, there are 8 data types. They are as
follows:
● boolean data type
● byte data type
● char data type
● short data type
● int data type
● long data type
● float data type
● double data type
NON PRIMITIVE DATA TYPE
●Non-Primitive Data Types: These data types are not actually defined by the
programming language but are created by the programmer. They are also called
“reference variables” or “object references” since they reference a memory
location which stores the data.
●Strings: String is a sequence of characters. But in Java, a string is an object
that represents a sequence of characters. The java.lang.String class is used to
create a string object. If you wish to know more about Java Strings, you can
refer to this article on Strings in Java.
●Arrays: Arrays in Java are homogeneous data structures implemented in Java
as objects. Arrays store one or more values of a specific data type and provide
indexed access to store the same. A specific element in an array is accessed by
its index. If you wish to learn Arrays in detail, then kindly check out this article on
Java Arrays.
LOOPS IN JAVA
●1.While loop
●2.For loop
●3.Dowhile loop
●while loop: A while loop is a control flow statement that allows code to be
executed repeatedly based on a given Boolean condition. The while loop
can be thought of as a repeating if statement
●Syntax:
● while(boolean condition)
●{
● loop statement;
●}
●EXAMPLE:
●class whileLoopDemo
●{
● public static void main(String args[])
● {
● int x = 1;
●
● // Exit when x becomes greater than 4
● while (x <= 4)
● {
● System.out.println("Value of x:" + x);
●for loop: for loop provides a concise way of writing the loop structure.
Unlike a while loop, a for statement consumes the initialization,
condition and increment/decrement in one line thereby providing a
shorter, easy to debug structure of looping.
●Syntax:
●for(initialisation condition;testing condition;increment/decrement)
●{
● statements...
●}
EXAMPLE:
●class forLoopDemo
●{
●Output:
●Value of x:2
●do while: do while loop is similar to while loop with only difference that it
checks for condition after executing the statements, and therefore is an
example of Exit Control Loop
●Syntax:
●do
●{
● statements..
●}
●while (condition);
●EXAMPLE:
●class dowhileloopDemo
●{
●A Java source file is a plain text file containing Java source code and
having . java extension. The . java extension means that the file is the Java
source file. ... If there is a public class in a file, the name of the file must
match the name of the public class
JAVA SOURCE FILE STRUCTURE