Topic 0: Java SE 7

3,017 views

Published on

Slides

Published in: Education
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
3,017
On SlideShare
0
From Embeds
0
Number of Embeds
1,661
Actions
Shares
0
Downloads
91
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Topic 0: Java SE 7

  1. 1. Topic 0 : Java SE 7 DDOOCP COMPILED BY: ER. PRADIP KHARBUJA
  2. 2. Java › Object-oriented programming language inherited from C++. › Java is strong typed programming language. › Developed by James Gosling, a software developer at Sun Microsystems in 1991 › Previously known as Oak › Later renamed as Java in 1995 and released for public use. › Java SE 7 is the first release of Java SE under the Oracle Corporation. COMPILED BY: ER. PRADIP KHARBUJA
  3. 3. Features of Java 1. Portability 2. Memory Management 3. Security 4. Distributed Access 5. Multithreading COMPILED BY: ER. PRADIP KHARBUJA
  4. 4. Types of Java Programs 1. Desktop Application a. Character User Interface ( CUI )  A console based application b. Graphical User Interface ( GUI ) 2. Web Application a. Applets b. Servlets COMPILED BY: ER. PRADIP KHARBUJA
  5. 5. Java Development Kit (JDK) › The development tools for Java provided as a part of the system. › JDK comprises of the following development tools : 1. java 2. javac 3. javacdoc 4. jar COMPILED BY: ER. PRADIP KHARBUJA
  6. 6. Java Platform Components 1. The Java Platform, Standard Edition (Java SE) – Most commonly used platform – Used to develop desktop and console – based applications 2. The Java Platform, Enterprise Edition (Java EE) – Used to build server side applications 3. The Java Platform, Micro Edition (Java ME) – Used to build Java applications for micro-devices such as mobile phones COMPILED BY: ER. PRADIP KHARBUJA
  7. 7. JVM or Java Runtime Environment (JRE ) › Java Virtual Machine › In other programming language, a compiler translates source code into machine code for a specific computer. › But in Java, a compiler translates the Java source code into an intermediate code known as bytecode. › Bytecode is the machine language for JVM and is not machine specific. › The machine specific code is generated by the Java interpreter which serves a mediator between a virtual machine and a real machine COMPILED BY: ER. PRADIP KHARBUJA
  8. 8. Compilation of Java Code › Process of compilation of Java code and conversion of bytecode into machine code COMPILED BY: ER. PRADIP KHARBUJA
  9. 9. Java API › Applications Program Interfaces (API) 1. java.awt 2. java.io 3. java.lang 4. java.math 5. java.net 6. java.sql 7. javax.swing 8. java.util COMPILED BY: ER. PRADIP KHARBUJA
  10. 10. Tokens in Java › Tokens are the smallest units or building blocks used for creating programs. › Six types of tokens in Java 1. Keyword 2. Identifier 3. Separator 4. Operator 5. Literal 6. Comment COMPILED BY: ER. PRADIP KHARBUJA
  11. 11. 1. Keyword › Predefined words that have specific meanings in Java. › Keywords cannot be used as names for variables, methods, or classes. The Java Keywords if for while do imports implements extends double float else return class interface void package new private public protected default switch super boolean char COMPILED BY: ER. PRADIP KHARBUJA
  12. 12. 2. Identifier › An identifier is a name given to a variable, method or class. › Rules for naming an identifier 1. It must start with an underscore, a letter or a dollar sign ($). 2. It may consist of a letter, a number, an underscore or a dollar sign. 3. Spaces are not allowed in between an identifier. 4. Identifiers are case sensitive. 5. Java keywords should not be used while naming an identifier. COMPILED BY: ER. PRADIP KHARBUJA
  13. 13. 3. Separator Name of the Separator Symbol Parentheses ( ) Braces { } Brackets [ ] Semicolon ; Comma , Period . COMPILED BY: ER. PRADIP KHARBUJA
  14. 14. 4. Operator › We will discuss in coming slide. COMPILED BY: ER. PRADIP KHARBUJA
  15. 15. 5. Literal › Value assigned to variable or constant. – 20 an integer literal – 12.344 a double literal – true a Boolean literal – ‘a’ a character literal – “Java” a string literal COMPILED BY: ER. PRADIP KHARBUJA
  16. 16. 6. Comment › Comments are the tokens that are ignored by compiler during the compilation of the program. › Used to describe the function of a particular code. › Two types of comment in Java 1. Single Line Comment › // This is a single line comment. 2. Multiple Line Comment › /* This is a multiple line comment. */ COMPILED BY: ER. PRADIP KHARBUJA
  17. 17. Data types › You cannot declare a variable without specifying its data type. › The type of data that can be stored in a variable. › 4 categories 1. Integer › byte, short, int, long 2. Character › char 3. Floating Point › float, double 4. Boolean › boolean COMPILED BY: ER. PRADIP KHARBUJA
  18. 18. Variables › Containers or placeholders to store data within a program. › The value of variable can be changed through out the program. › Syntax : – <dataType> <identifier>; //declaring variable › E.g. – int a; – float b, c, d; – char x; – int a = 20, b = 40; – boolean x; COMPILED BY: ER. PRADIP KHARBUJA
  19. 19. Operators › String Operator › Arithmetic operators – Binary Operators – Unary Operators › Assignment operators › Comparison operators › Logical operators › Conditional Operators COMPILED BY: ER. PRADIP KHARBUJA
  20. 20. 1. String Operator + › It is used to concate or join two or more strings. COMPILED BY: ER. PRADIP KHARBUJA
  21. 21. 2. Arithmetic Operators Opertor Meaning + - * / % Modulus › Binary Operator – Needs two operands COMPILED BY: ER. PRADIP KHARBUJA
  22. 22. 2. Arithmetic Operators › Unary Operator – Needs only one operand ++ -- - COMPILED BY: ER. PRADIP KHARBUJA
  23. 23. 3. Assignment Operators Opertor Example Is same as Meaning = a = b a = b Assignment += a += b a = a + b Addition Assignment *= a *= b a = a * b Multiplication Assignment -= a -= b a = a – b Subtraction Assignment /= a /= b a = a / b Division Assignment %= a %= b a = a % b Modulus Assignment COMPILED BY: ER. PRADIP KHARBUJA
  24. 24. 4. Comparison Operators › Compares two values and returns a Boolean value. Operator Example == equal to != not equal to < less than > greater than >= greater than or equal to <= less than or equal to COMPILED BY: ER. PRADIP KHARBUJA
  25. 25. 5. Logical Operators › They operates only on the boolean operands and produce the boolean result. › They are used in compound condition. › Write the truth table of OR, AND operators for 3 inputs. › Write the truth table of NOT operator. Operator Meaning || OR && AND ! NOT COMPILED BY: ER. PRADIP KHARBUJA
  26. 26. 6. Conditional Operator › It assigns value to a variable based on the specific condition. › It is a ternary operator. It requires 3 operands. › Syntax : (condition)?expression1:expression2 COMPILED BY: ER. PRADIP KHARBUJA
  27. 27. Operator Precedence › Increment and decrement operations › Arithmetic operators › Comparison operators › Logical operators › Assignment operators COMPILED BY: ER. PRADIP KHARBUJA
  28. 28. Find the output COMPILED BY: ER. PRADIP KHARBUJA
  29. 29. Control Flow Statements 1. Decision Making Statements a. if else statement b. switch statement 2. Looping Statements a. for loop b. while loop c. do while loop 3. Jump Statements a. break b. continue COMPILED BY: ER. PRADIP KHARBUJA
  30. 30. if else statement COMPILED BY: ER. PRADIP KHARBUJA
  31. 31. switch Statement COMPILED BY: ER. PRADIP KHARBUJA
  32. 32. switch Statement › Write a program to find whether a character is vowel or not. COMPILED BY: ER. PRADIP KHARBUJA
  33. 33. for loop › Display 1 to 10; › Display even number from 1 to 100. › WAP to find the factorial of the given number. › Find whether a given number is prime or not. COMPILED BY: ER. PRADIP KHARBUJA
  34. 34. while loop › Display odd number from 1 to 100. COMPILED BY: ER. PRADIP KHARBUJA
  35. 35. do while loop › WAP to take input from user until user enters 0. › WAP to take input from user until user enters "Bye“. › WAP to sum until user enter 0. Display the sum. COMPILED BY: ER. PRADIP KHARBUJA
  36. 36. Nested Loop COMPILED BY: ER. PRADIP KHARBUJA
  37. 37. break Statement › WAP to display first five odd numbers. COMPILED BY: ER. PRADIP KHARBUJA
  38. 38. continue Statement › WAP to display from 1 to 100. But don’t display multiples of 5. COMPILED BY: ER. PRADIP KHARBUJA
  39. 39. Array › An array is a collection of similar type of data. › It helps to store multiple data under same name. › Its index always starts from 0. › Two categories – One-dimensional array – Two-dimensional array COMPILED BY: ER. PRADIP KHARBUJA
  40. 40. One-Dimensional Array › WAP to declare array of full name and age. The size of array must be taken from user. Take the full name and age and display them. COMPILED BY: ER. PRADIP KHARBUJA
  41. 41. Two-Dimensional Array COMPILED BY: ER. PRADIP KHARBUJA
  42. 42. Next Class… 1. What is a class? 2. What is an object? 3. Constructor 4. Method Overloading 5. Packages 6. Inner Class COMPILED BY: ER. PRADIP KHARBUJA

×