Chapter 5 server Side Scripting Date: 01 October 2017.

Slides:



Advertisements
Similar presentations
Classes And Objects II. Recall the LightSwitch Class class LightSwitch { boolean on = true; boolean isOn() { return on; } void switch() { on = !on; }
Advertisements

Continuation of chapter 6…. Nested while loop A while loop used within another while loop is called nested while loop. Q. An illustration to generate.
AP Computer Science Anthony Keen. Computer 101 What happens when you turn a computer on? –BIOS tries to start a system loader –A system loader tries to.
Programming for Beginners Martin Nelson Elizabeth FitzGerald Lecture 3: Flow Control I: For Loops.
STRING AN EXAMPLE OF REFERENCE DATA TYPE. 2 Primitive Data Types  The eight Java primitive data types are:  byte  short  int  long  float  double.
Fundamental Programming Structures in Java: Control Flow, Arrays and Vectors.
Chapter 41 Variables and JSP Control Structures JavaServer Pages By Xue Bai.
Introduction to Control Statements Presented by: Parminder Singh BCA 5 th Sem. [ Batch] PCTE, Ludhiana 5/12/ Control Statements.
5/17/ Programming Constructs... There are several types of programming constructs in JAVA. - If-else construct or ternary operator - while - do-while.
1 Chapter 4 Language Fundamentals. 2 Identifiers Program parts such as packages, classes, and class members have names, which are formally known as identifiers.
Some basic I/O.
Introduction to Java CS 331. Introduction Present the syntax of Java Introduce the Java API Demonstrate how to build –stand-alone Java programs –Java.
Java Object and Class in Java. Java Naming conventions A naming convention is a rule to follow as you decide what to name your identifiers e.g. class,
JAVA PROGRAMMING PART II.
1 Identifiers  Identifiers are the words a programmer uses in a program  An identifier can be made up of letters, digits, the underscore character (
General Features of Java Programming Language Variables and Data Types Operators Expressions Control Flow Statements.
By Nicholas Policelli An Introduction to Java. Basic Program Structure public class ClassName { public static void main(String[] args) { program statements.
Introduction to Programming David Goldschmidt, Ph.D. Computer Science The College of Saint Rose Java Fundamentals (Comments, Variables, etc.)
Control Structures if else do while continue break switch case return for.
Basic Java Programming CSCI 392 Week Two. Stuff that is the same as C++ for loops and while loops for (int i=0; i
Outline Character Strings Variables and Assignment Primitive Data Types Expressions Data Conversion Interactive Programs Graphics Applets Drawing Shapes.
Hello.java Program Output 1 public class Hello { 2 public static void main( String [] args ) 3 { 4 System.out.println( “Hello!" ); 5 } // end method main.
Chapter 2: Java Fundamentals
Programming for Beginners Martin Nelson Elizabeth FitzGerald Lecture 2: Variables & Data Types.
Session Three Review & Conditional Control Flow. Java File Hierarchy Projects Packages Classes Methods.
An Introduction to Java – Part 1 Dylan Boltz. What is Java?  An object-oriented programming language  Developed and released by Sun in 1995  Designed.
Java development environment and Review of Java. Eclipse TM Intergrated Development Environment (IDE) Running Eclipse: Warning: Never check the “Use this.
CS177 Week2: Recitation Primitive data types and Strings with code examples.
JAVA (something like C). Object Oriented Programming Process orientated – code acting on data Object oriented – data controls access to code Encapsulation.
Introduction to Java Lecture Notes 3. Variables l A variable is a name for a location in memory used to hold a value. In Java data declaration is identical.
Assignment An assignment statement changes the value of a variable The assignment operator is the = sign total = 55; Copyright © 2012 Pearson Education,
BEGINNING PROGRAMMING.  Literally – giving instructions to a computer so that it does what you want  Practically – using a programming language (such.
Sahar Mosleh California State University San MarcosPage 1 Program Control Statement.
Java Language Basics By Keywords Keywords of Java are given below – abstract continue for new switch assert *** default goto * package.
1 Basic Java Constructs and Data Types – Nuts and Bolts Looking into Specific Differences and Enhancements in Java compared to C.
School of Computer Science & Information Technology G6DICP - Lecture 4 Variables, data types & decision making.
Operators in JAVA. Operator An operator is a symbol that operates on one or more arguments to produce a result. Java provides a rich set of operators.
1 More data types Character and String –Non-numeric variables –Examples: char orange; String something; –orange and something are variable names –Note.
Java Nuts and Bolts Variables and Data Types Operators Expressions Control Flow Statements Arrays and Strings.
Java Part I By Wen Fei, HAO. Program Structure public class ClassName { public static void main(String[] args) { program statements } user defined methods.
A Introduction to Computing II Lecture 1: Java Review Fall Session 2000.
1 Lecture # 2. * Introducing Programming with an Example * Identifiers, Variables, and Constants * Primitive Data Types * Byte, short, int, long, float,
Chapter 7 Control Structures. Java has very flexible three looping mechanisms. You can use one of the following three loops:  while Loop  do...while.
CSE 110: Programming Language I Matin Saad Abdullah UB 1222.
 It is a pure oops language and a high level language.  It was developed at sun microsystems by James Gosling.
April 13, 1998CS102-02Lecture 3-1 Data Types in Java CS Lecture 3-1 Java’s Central Casting.
JAVA MULTIPLE CHOICE QUESTION.
Programming in Java Sachin Malhotra, Chairperson, PGDM-IT, IMS Ghaziabad Saurabh Chaudhary, Dean, Academics, IMS Ghaziabad.
Sachin Malhotra Saurabh Choudhary
Yanal Alahmad Java Workshop Yanal Alahmad
Lecture 2: Data Types, Variables, Operators, and Expressions
CS180 – Week 1 Lecture 3: Foundation Ismail abumuhfouz.
An Introduction to Java – Part I
Chapter 2.
مفاهیم اولیه زبان جاوا Java Basic Concepts
Operators and Expressions
Escape Sequences What if we wanted to print the quote character?
Starting JavaProgramming
null, true, and false are also reserved.
Introduction to Java Programming
An Introduction to Java – Part I, language basics
An overview of Java, Data types and variables
Chapter 2: Java Fundamentals
Units with – James tedder
class PrintOnetoTen { public static void main(String args[]) {
Lecture Notes – Week 2 Lecture-2
Module 2 - Part 1 Variables, Assignment, and Data Types
Chap 2. Identifiers, Keywords, and Types
Agenda Types and identifiers Practice Assignment Keywords in Java
Introduction to java Part I By Shenglan Zhang.
Presentation transcript:

Chapter 5 server Side Scripting Date: 01 October 2017

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

SERVER SIDE SCRIPTING

Client-Server Side

Life Cycle of JSP

JAVA TECHNOLOGY

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

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

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

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

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

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); }

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

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);    } } 

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   }

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

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");        }   }  

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");        }   }   }

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!!!”); }   }

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!!!”); }   }

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

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");        }   }   } 

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

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

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

Part III: Object Class Object Class Inheritance Polymorphism Abstraction Encapsulation

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.

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);     }   }  

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);     }  

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:-

To be continue.....