Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter 5 server Side Scripting Date: 01 October 2017.

Similar presentations


Presentation on theme: "Chapter 5 server Side Scripting Date: 01 October 2017."— Presentation transcript:

1 Chapter 5 server Side Scripting Date: 01 October 2017

2 Outlines Server Side Scripting Java Technology
Part I: Variables, constants, expression Part II: Functions & control structures Part III: Object Class Object, Class, Inheritance, Polymorphism, Abstraction, Encapsulation

3 SERVER SIDE SCRIPTING

4 Client-Server Side

5 Life Cycle of JSP

6 JAVA TECHNOLOGY

7 Variables, constants & expression
public class FirstJava { public static void main(String[] args) { system.out.println(“My First JAVA Project"); }

8 What happens at compile time?
JAVA Code Byte Code Compile Simple.java Simple.class

9 Variables in JAVA Types of variables Local variable Instance variable
Static variable

10 Variables in JAVA class A{ int data=50; //instance variable
static int m=100; //static variable   void method(){   int n=90; //local variable   }   } //end of class

11 Data Types in JAVA Data Type Default Value Default Size boolean false
1 bit char ‘u\0000’ 2 byte byte 1 byte short int 4 byte long 0L 8 byte float 0.0f double 0.0d

12 Data Types in JAVA public class B {
public static void main(String[] args){ int a=10; int b=10; int c=a+b; System.out.println(c); }

13 Operator in JAVA Operator in java is symbols to perform operation such as +, -, *, /, etc.

14 Operator in JAVA (Assignment)
class OperatorExample{   public static void main(String[] args){   int a=10;   int b=5;   System.out.println(a+b); System.out.println(a-b);    System.out.println(a*b);    System.out.println(a/b);    System.out.println(a%b);    }

15 Operator in JAVA (Relational)
class OperatorExample { public static void main(String args[]) { int a=10; int b=5; int c=20; System.out.println(a<b&&a++<c);//false && true = false    System.out.println(a);//10 because second condition is not checked   System.out.println(a<b&a++<c);//false && true = false   System.out.println(a);//11 because second condition is checked   }

16 Part II: Function & Control Structure
If statement If-else statement Nested if statement If-else-if ladder

17 If Statement Example:- public class Example1 {
public static void main(String[] args) {        int age=20;        if(age>18){            System.out.print("Age is greater than 18");        }   }  

18 If-Else Statement Example:- public class Example2 {
public static void main(String[] args) {        int number=13;        if(number%2==0){            System.out.println("even number");        } else {            System.out.println("odd number");        }   }   }

19 Nested If Statement Example: public class Example3 {
public static void main(String[] args) {        int number=13;        if(number%2==0){            System.out.println("even number");        } else if {            System.out.println("odd number");        } else { System.out.println(“Error!!!”); }   }

20 If-Else-If Statement Example:- public class Example4 {
public static void main(String[] args) {        int number=85;        if(number>=80 && number<=100) {            System.out.println(“Grade A");        } else if (number>=79 && number<=60) {            System.out.println(“Grade B");        } else { System.out.println(“Error!!!”); }   }

21 Part II: Function & Control Structure
Switch For Loop While Loop Do While

22 Switch Example:- public class SwitchExample {
public static void main(String[] args) {        int number=20;        switch(number){        case 10: System.out.println("10");break;        case 20: System.out.println("20");break;        case 30: System.out.println("30");break;        default:System.out.println("Not in 10, 20 or 30");        }   }  

23 For Loop Example:- public class LoopExample {
public static void main(String[] args) {        for(int i=1;i<=10;i++){   System.out.println(i);        }   }   }

24 While Loop Example:- public class WhileExample {
public static void main(String[] args) {        int i=1;        while(i<=10){            System.out.println(i);        i++;        }   }  

25 Do-While Example public class DoWhileExample {
public static void main(String[] args) {        int i=1;        do {            System.out.println(i);        i++;   } while(i<=10);   }  

26 Part III: Object Class Object Class Inheritance Polymorphism
Abstraction Encapsulation

27 Naming Conventions Naming conventios Name Convention class name
Should start with uppercase letter and be a noun e.g. String, Color, Button, System, Thread etc. interface name Should start with uppercase letter and be an adjective e.g. Runnable, Remote, ActionListener etc. method name Should start with lowercase letter and be a verb e.g. actionPerformed(), main(), print(), println() etc. variable name Should start with lowercase letter e.g. firstName, orderNumber etc. package name Should be in lowercase letter e.g. java, lang, sql, util etc. constants name Should be in uppercase letter. e.g. RED, YELLOW, MAX_PRIORITY etc.

28 Object & Class Example 1:- class Student{
  int id;//field or data member or instance variable     String name;        public static void main(String args[]) {      Student s1=new Student();//creating an object of Student      System.out.println(s1.id);//accessing member through reference variable      System.out.println(s1.name);     }   }  

29 Object & Class Example 2:- class Student{ int id; String name; }
}   class TestStudent3{   public static void main(String args[]){      Student s1=new Student();  // create objects    Student s2=new Student();  // create objects      s1.id=101;      s1.name=“Lukaku";      s2.id=102;      s2.name=“Lukamu";      System.out.println(s1.id+" "+s1.name);      System.out.println(s2.id+" "+s2.name);     }  

30 Object & Class Example 3:- class Employee{ int id; String name;
    float salary;       void insert(int i, String n, float s) {           id=i;           name=n;           salary=s;       }       void display(){System.out.println(id+" "+name+" "+salary);}   }   public class TestEmployee {   public static void main(String[] args) {        Employee e1=new Employee();        e1.insert(101,"ajeet",45000);       e1.display();   Example 3:-

31 To be continue.....


Download ppt "Chapter 5 server Side Scripting Date: 01 October 2017."

Similar presentations


Ads by Google