Introduction to JAVA

Views:
 
Category: Education
     
 

Presentation Description

Introduction to Java, specially for ICSE Computer Applications

Comments

Presentation Transcript

A mind is like a parachute. It doesn't work if it is not open. : 

A m in d is lik e a p ar ach ut e . It d o e s n ' t wor k if it i s n o t o p e n .

Remember When I give you my time, I’m giving you a portion of my life that I will never get back. So don’t waste it.

Introduction to JAVA: 

Java Programming 3 Introduction to JAVA Java is an island in Indonesia, or you can say Java is type of coffee, but Java is most popular as a programming language. In 1991 Java programming language stepped into the world and got determinant status.

Introduction to JAVA: 

Java Programming 4 Introduction to JAVA Java was developed by a team of computer professionals under the guidance of James Gosling at Sun Microsystems in 1991. Initially they called it “ OAK ” after seeing an oak tree from their window, but after some weeks they were sipping Java coffee, so one of them suggested the name “Java”.

Introduction to JAVA: 

Java Programming 5 Introduction to JAVA Java is simple, scalable (easy to integrate), object oriented, general purpose programming language with powerful features, which can be used to develop a variety of application from.

Introduction to JAVA: 

Java Programming 6 Introduction to JAVA Generally a language is either complied or interpreted, but Java is both complied and interpreted. First a Java is complied and comes in the form of JAVA BYTE CODE. Then this Java code is run on interpreter to execute a program. This Java Byte Code is the actual power of Java to make it powerful and dominating over other programming languages.

PowerPoint Presentation: 

Java Programming 7 It is a high-level programming language (closer to human language than machine code) ‏ it is event-driven (it responds to user mouse clicks and key presses Why Java?

PowerPoint Presentation: 

Java Programming 8 Programs come as two types: applications (run on their own) and applets (run in a web browser, making a more user-friendly running environment) ‏ Ready-made applets can be downloaded from the internet and run within a browser Why Java?

PowerPoint Presentation: 

Java Programming 9 Executables in other languages have too much access to the system and can't be trusted – the sandboxing in Java means it is virtually impossible to write a virus or crash the whole system. Why Java? Sandbox is a security mechanism for safely running programs. The sandbox typically provides a tightly-controlled set of resources for guest programs to run in, such as scratch space on disk and memory.

PowerPoint Presentation: 

Java Programming 10 It is effectively a platform in itself and so is platform-independent (programs will run on Windows, Macs, Linux, etc.). The Java compiler creates byte code which is standard and will be converted to the machine's native code at run time Why Java?

PowerPoint Presentation: 

Java Programming 11 It is simpler than other languages so easier to learn, so fewer bugs and bugs are easier to spot it is object-oriented which makes it easy to work with GUI (window-based) interfaces. Why Java?

PowerPoint Presentation: 

Java Programming 12 It is multithreaded , meaning programs can run several tasks simultaneously, (as can Windows), unlike older style procedural programs Why Java?

PowerPoint Presentation: 

Java Programming 13 The different files ( classes ) of a Java project are independent but dynamically linked so they can use each other automatically when required Why Java?

PowerPoint Presentation: 

Java Programming 14 Memory allocation is more efficient than in other languages (Java uses what is called garbage collection to liberate memory that is no longer needed) ‏ Why Java? Continue…Java BlueJ

What is Java Technology?: 

What is Java Technology? The Java technology is: – A programming language – A development environment – An application environment – A deployment environment Java Programming 15

Programming Language: 

Programming Language As a programming language, Java can create all kinds of applications that you could create using any conventional programming language . Java Programming 16

A Development Environment: 

A Development Environment As a development environment, Java technology provides you with a large suite of tools: – A compiler ( javac ) – An interpreter (java) – A documentation generator ( javadoc ) – A class file packaging tool and so on... Java Programming 17

An Application and Runtime Environment: 

An Application and Runtime Environment Java technology applications are typically general-purpose programs that run on any machine where the Java runtime environment (JRE) is installed. There are two main deployment environments: The JRE supplied by the Java Software Development Kit (SDK ) contains the complete set of class files for all the Java technology packages , which includes basic language classes, GUI component classes , and so on. The other main deployment environment is on your web browser . Most commercial browsers supply a Java technology interpreter and runtime environment. Java Programming 18

BlueJ A Very Quick Introduction Java Programming 19

BlueJ: 

BlueJ BlueJ is an IDE (Integrated Development Environment). It includes an editor, which you use to write your programs a debugger, to help you find your mistakes a viewer, to see the parts of your program an easy way to run Java programs an easy way to view documentation

Open BlueJ, choose New Project: 

Open BlueJ , choose New Project

Name the project, click Create: 

Name the project, click Create

Create and name a new Class: 

Create and name a new Class The name of the class should begin with a capital letter

Double-click the new class to edit it: 

Double-click the new class to edit it The stripes show that the class "Drawing" is not compiled (ready to run)

Edit your class, then Compile it: 

Edit your class, then Compile it BlueJ starts you with a simple class or a simple applet. You can modify what BlueJ gives you, or just replace it with your own program. You must compile before you can run.

If application: right-click and choose void main(): 

If application: right-click and choose void main ()

Application: Just click Ok: 

Application: Just click Ok

Application results: 

Application results

Final Notes: 

Final Notes You don't have to Save your work— BlueJ does that automatically for you when you compile If you quit BlueJ and come back later, use Open Project to continue where you left off Over for BlueJ

Basic Features: 

Java Programming 30 Basic Features Platform Independent Object Oriented Easy to learn Robust Secure Code Security Dynamic High Performance Multi-threaded Garbage Collection

Java Virtual Machine Concept: 

Java Programming 31 Java Virtual Machine Concept When a Java program is compiled it is converted to “byte code” which is then executed by the Java interpreter by translating the byte code into the machine intructions.

Java Virtual Machine Concept: 

Java Programming 32 Java Virtual Machine Concept Java interpreter is part of Java runtime environment. Byte code is an intermediate code independent of any machine or operating system. Program in Java run time environment, which is used to interpret byte code, is called Java Virtual Machine (JVM). The Java compiler reads Java language source files, translates the source into Java byte code and places the byte code into class files.

Java Virtual Machine Concept: 

Java Programming 33 Java Virtual Machine Concept The Java Virtual Machine (JVM) plays the main role to making Java portable. It provides a layer of abstraction between the compiled Java program and the hardware platform and operating system. The JVM is central to Java’s portability because compiled Java program runs on the JVM, independent of whatever hardware is used.

PowerPoint Presentation: 

Java Programming 34 Parts of a program are divided into blocks , surrounded by braces {..}. There must be an equal number of opening and closing braces in your programs. The other types of bracket, (...) and [...] are also used but for different purposes, and the same rule applies. Blocks and indentation

PowerPoint Presentation: 

Java Programming 35 All lines apart from comments and those with braces must end with a semi-colon (;). Always start the contents of a new block with a tab ( indent its contents) - otherwise it will be impossible to spot errors later. Blocks and indentation

Java Tokens: 

Java Tokens In a Java program, all characters are grouped into symbols called tokens. Java Programming 36 token <= identifier | keyword | separator | operator | literal | commen t

Java Tokens: 

Java Tokens Identifiers: names the programmer chooses Keywords: names already in the programming language Separators (also known as punctuators): punctuation characters and paired-delimiters Java Programming 37

Java Tokens: 

Java Tokens Operators : symbols that operate on arguments and produce results Literals (specified by their type ) Numeric: int and double Logical: boolean Textual: char and String Reference: null Comments Line Block Java Programming 38

Identifiers: 

Identifiers Identifiers are used by programmers to name things in Java: things such as variables, methods, fields, classes, interfaces, exceptions, packages , etc. Java Programming 39

Naming Convention: 

Java Programming 40 Naming Convention Java programming language has its own set of rules and conventions for the kinds of names: Variable names are case-sensitive. A variable's name can be any legal identifier — an unlimited-length sequence of Unicode letters and digits, beginning with a letter, the dollar sign "$", or the underscore character "_". If the name you choose consists of only one word, spell that word in all lowercase letters. If it consists of more than one word, capitalize the first letter of each subsequent word. Keep in mind that the name you choose must not be a keyword or reserved word.

Keywords: 

Keywords The second category of token is a Keyword, sometimes called a reserved word. Keywords are identifiers that Java reserves for its own use. These identifiers have built-in meanings that cannot change. Thus, programmers cannot use these identifiers for anything other than their built-in meanings. Java Programming 41

List of 49 Keywords: 

List of 49 Keywords abstract continue goto package switch assert default if private this boolean do implements protected throw break double import public throws byte else instanceof return transient case extends int short try catch final interface static void char finally long strictfp volatile class float native super while const for new synchronized Java Programming 42

Separators: 

Separators The third category of token is a Separator. There are exactly nine. ; Semicolon , Comma . Dot ( ) { } [ ] Java Programming 43 The last six separators (3 pairs of 2 each) are also known as delimiters.

Operators: 

Operators The fourth category of token is an Operator. Java includes 37 operators that are listed in the table below; each of these operators consist of 1, 2, or at most 3 special characters. Java Programming 44 = > < ! ~ ? : == <= >= != && || ++ -- + - * / & | ^ % << >> >>> += -= *= /= &= |= ^= %= <<= >>= >>=

Literals: 

Literals The fifth, and most complicated category of tokens is the Literal. All values that we write in a program are literals. Java Programming 45

Escape Sequences: 

Escape Sequences Prints something in a special way Java Programming 46 Escape Sequence Meaning \n new line \t horizontal tab \v vertical tab \b backspace \r carriage return \f form feed \a bell \\ \ (needed to denote \ in a text literal) \' ' (does not act as the right ' of a char literal) \" " (does not act as the right " of a String literal)

PowerPoint Presentation: 

Java Programming 47 Comments are ignored by the compiler i.e. they are non-executable statements. Everything between /* and */ and on a single line after //. Use the /* */ style comments to "comment out" multiple lines for debugging.(spotting problems in your code). Comments

Variables : 

Java Programming 48 Variables Variables are named memory/storage locations where data can be stored, each variable can hold one of the data types. A variable holds one piece od data at a time. The Java programming language defines the following kinds of variables: Instance Variables (Non-Static Fields) Class Variables (Static Fields) Local Variables

Data Type: 

Data Type classification of a particular type of information . Variables are placeholders used to store values; they have names and data types. The data type of a variable determines how the bits representing those values are stored in the computer's memory. When you declare a variable, you can also supply a data type for it. All variables have a data type that determines what kind of data they can store. Java Programming 49

Data Type: 

Data Type Java supports two types: Primitive or Basic Data Type Composite Data Type Java Programming 50

Primitive/Basic Data Types : 

Java Programming 51 Primitive/Basic Data Types The Java programming language is statically-typed, which means that all variables must first be declared before they can be used. Syntax data_type identifier[=initial_value];

Primitive/Basic Data Types: 

Java Programming 52 Primitive/Basic Data Types byte short int long float double boolean char Note>> Strings, which are widely used in Java programming, are a sequence of characters. In the Java programming language, strings are objects. The Java platform provides the String class to create and manipulate strings.

byte: 

byte The byte data type is an 8-bit signed two's complement integer. It has a minimum value of -128 and a maximum value of 127 (inclusive). The byte data type can be useful for saving memory, where the memory savings actually matters. They can also be used in place of int where their limits help to clarify your code; the fact that a variable's range is limited can serve as a form of documentation. Java Programming 53

short: 

short The short data type is a 16-bit signed two's complement integer. It has a minimum value of -32,768 and a maximum value of 32,767 (inclusive). You can use a short to save memory in large arrays, in situations where the memory savings actually matters. Java Programming 54

int: 

int The int data type is a 32-bit signed two's complement integer. It has a minimum value of -2,147,483,648 and a maximum value of 2,147,483,647 (inclusive). Java Programming 55

long: 

long The long data type is a 64-bit signed two's complement integer. It has a minimum value of - 9,223,372,036,854,775,808 and a maximum value of 9,223,372,036,854,775,807 ( inclusive). Use this data type when you need a range of values wider than those provided by int. Java Programming 56

float: 

float float can handle about 7 decimal places. Java Programming 57

double: 

double A double data type is basically short for "double float“. A double can handle about 16 decimal places. Java Programming 58

boolaen: 

boolaen The boolean data type has only two possible values: true and false. Use this data type for simple flags that track true/false conditions. This data type represents one bit of information, but its "size" isn't something that's precisely defined. Java Programming 59

char: 

char The char data type is a single 16-bit Unicode character. It has a minimum value of '\u0000' (or 0) and a maximum value of '\ uffff ' (or 65,535 inclusive). Java Programming 60

Default Values: 

Default Values Data Type Default Value (for fields) byte 0 short 0 int 0 long 0L float 0.0f double 0.0d char '\u0000' String (or any object) null boolean false Java Programming 61  It's not always necessary to assign a value when a field is declared. Fields that are declared but not initialized will be set to a reasonable default by the compiler. Generally speaking, this default will be zero or null, depending on the data type. Relying on such default values, however, is generally considered bad programming style.

Arrays : 

Java Programming 62 Arrays An array is a container object that holds a fixed number of values of a single type. The length of an array is established when the array is created. After creation, its length is fixed.

Composite Data Type: 

Composite Data Type Java Programming 63

Arrays: 

Java Programming 64 Arrays Each item in an array is called an element , and each element is accessed by its numerical index .

Arrays: 

Java Programming 65 Arrays Syntax data_type[] arrayName; Example(s) int[] anArray; // declares an array of integers double[] anArrayOfDoubles; char[] anArrayOfChars;

Arrays: 

Java Programming 66 Arrays One way to create an array is with the new operator. anArray = new int[10]; // create an array of 10-integers You can also declare an array of arrays (also known as a multidimensional array) by using two or more sets of square brackets, such as int[][] names.

Operators : 

Java Programming 67 Operators Operators are special symbols that perform specific operations on one, two, or three operands , and then return a result.

The Simple Assignment Operator : 

Java Programming 68 The Simple Assignment Operator Assignment operator assigns the value on its right to the operand on its left. Example: int i=10;\\assigns value 10 to variable i

The Arithmetic Operators : 

Java Programming 69 The Arithmetic Operators + additive operator (also used for String concatenation) - subtraction operator * multiplication operator / division operator % remainder operator

The Unary Operators : 

Java Programming 70 The Unary Operators The unary operators require only one operand. + Unary plus operator; indicates positive value (numbers are positive without this, however) - Unary minus operator; negates an expression ++ Increment operator; increments a value by 1 -- Decrement operator; decrements a value by 1 ! Logical complement operator; inverts the value of a boolean

The Equality and Relational Operators : 

Java Programming 71 The Equality and Relational Operators The equality and relational operators determine if one operand is greater than, less than, equal to, or not equal to another operand. == equal to != not equal to > greater than >= greater than or equal to < less than <= less than or equal to

The Conditional Operators : 

Java Programming 72 The Conditional Operators The && and || operators perform Conditional-AND and Conditional-OR operations on two/more boolean expressions. These operators exhibit "short-circuiting" behavior, which means that the second operand is evaluated only if needed. && Conditional-AND || Conditional-OR

Ternary Operator: 

Java Programming 73 Ternary Operator ?: Ternary Operator (shorthand for if-then-else statement) Example result = someCondition ? value1 : value2;  If someCondition is true, assign the value of value1 to result. Otherwise, assign the value of value2 to result

Bitwise and Bit Shift Operators : 

Java Programming 74 Bitwise and Bit Shift Operators The unary bitwise complement operator "~" inverts a bit pattern; it can be applied to any of the integral types, making every "0" a "1" and every "1" a "0". For example, a byte contains 8 bits; applying this operator to a value whose bit pattern is "00000000" would change its pattern to "11111111".

Bitwise and Bit Shift Operators : 

Java Programming 75 Bitwise and Bit Shift Operators The signed left shift operator "<<" shifts a bit pattern to the left, and the signed right shift operator ">>" shifts a bit pattern to the right. The bit pattern is given by the left-hand operand, and the number of positions to shift by the right-hand operand. The unsigned right shift operator ">>>" shifts a zero into the leftmost position, while the leftmost position after ">>" depends on sign extension.

Bitwise and Bit Shift Operators : 

Java Programming 76 Bitwise and Bit Shift Operators The bitwise & operator performs a bitwise AND operation. The bitwise ^ operator performs a bitwise exclusive OR operation. The bitwise | operator performs a bitwise inclusive OR operation.

Expressions : 

Java Programming 77 Expressions An expression is a construct made up of variables, operators, and method invocations, which are constructed according to the syntax of the language, that evaluates to a single value.

Statements : 

Java Programming 78 Statements Statements are roughly equivalent to sentences in natural languages. A statement forms a complete unit of execution.

Blocks: 

Java Programming 79 Blocks A block is a group of zero or more statements between balanced braces and can be used anywhere a single statement is allowed.

Control Flow Statements : 

Java Programming 80 Control Flow Statements Control flow statements break up the flow of execution by employing decision making, looping, and branching, enabling your program to conditionally execute particular blocks of code.

Decision Making- Selection: 

Java Programming 81 Decision Making- Selection These statements allow you to control the flow of execution based upon conditions known only during the run-time. Java supports two selection statements: if-else and switch.

Decision Making- Selection: 

Java Programming 82 Decision Making- Selection If Statement: Syntax: if <condition> statement-1 [else Statement-2] We can use nested/multilevel if .

Iterative Statements-Loops: 

Java Programming 83 Iterative Statements-Loops Java iteration statements are: while do…while, and for

Iterative Statements-Loops: 

Java Programming 84 Iterative Statements-Loops The while and do…while statement:- A while statement is used to continually execute a block of statements provided a condition remains true. The general syntax of while statement is: while<condition_expression> { valid java statement(s); }

Iterative Statements-Loops: 

Java Programming 85 Iterative Statements-Loops The general syntax of do…while is:- do { Valid java statement(s); } while<condition_expression>; The do…while evaluates the expression at the bottom instead of evaluating it at the top of the loop. Thus the code block associated with a do…while is executed at least once.

Iterative Statements-Loops: 

Java Programming 86 Iterative Statements-Loops The for statement provides a compact way to iterate over a range of values. Programmers often refer to it as the "for loop" because of the way in which it repeatedly loops until a particular condition is satisfied. The general form of the for statement can be expressed as follows:

Iterative Statements-Loops: 

Java Programming 87 Iterative Statements-Loops for ( initialization ; termination ; increment ) { statement(s) } When using this version of the for statement, keep in mind that: The initialization expression initializes the loop; it's executed once, as the loop begins. When the termination expression evaluates to false, the loop terminates. The increment expression is invoked after each iteration through the loop; it is perfectly acceptable for this expression to increment or decrement a value.

Branching/Jump Statements : 

Java Programming 88 Branching/Jump Statements The break Statement: The break statement has two forms: labeled and unlabeled. Unlabeled:- An unlabeled break statement terminates the innermost switch, for, while, or do-while statement and transfers the control to the statement following the control statement.

Branching/Jump Statements: 

Java Programming 89 Branching/Jump Statements Labeled:-

Branching/Jump Statements: 

Java Programming 90 Branching/Jump Statements The continue Statement: The continue statement skips the current iteration of a for, while , or do-while loop.

Methods: 

Java Programming 91 Methods A Java method is a set of Java statements that can be included inside a Java class . Every Java program must have one main method. The main method is the first method which the Java Virtual Machine executes. The main method then calls the other methods, as they are needed .

Methods: 

Java Programming 92 Methods A method is a set of code which is referred to by name and can be called (invoked) at any point in a program simply by utilizing the method's name. Think of a method as a subprogram that acts on data and often returns a value . Each method has its own name.  When that name is encountered in a program, the execution of the program branches to the body of that method.  When the method is finished, execution returns to the area of the program code from which it was called, and the program continues on to the next line of code . Methods are time savers, in that they allow for the repetition of sections of code without retyping the code.

PowerPoint Presentation: 

Java Programming 93 The first line of a method is called the signature. Contains: access modifier (scope) ‏ return type name any parameter types and names public static int average (numbers) ‏ Signatures

PowerPoint Presentation: 

Java Programming 94 This means how far across the program a variable or method applies. A variable only applies in the block ( {.......}) in which it is declared. So many variables declared public at the start of the class Scope

PowerPoint Presentation: 

Java Programming 95 For now, use the static keyword when declaring a method as it makes the method relevant to the whole class Static methods

PowerPoint Presentation: 

Java Programming 96 Using public makes the variable or method available throughout the program. Always use public for now. Scope

PowerPoint Presentation: 

Java Programming 97 Pass any necessary information over to a method in the brackets after it e.g. to run the inputInt (String prompt) method, call something like inputInt ("What is your age?"); so that the method can make use of the String, which it will call prompt . Parameter passing

PowerPoint Presentation: 

Java Programming 98 Every method must have round brackets even if it has no parameters to be passed. Parameter passing

The return Statement: 

Java Programming 99 The return Statement The return statement exits from the current method, and control flow returns to where the method was invoked. The return statement has two forms: one that returns a value, and one that doesn't. To return a value, simply put the value (or an expression that calculates the value) after the return keyword. return ++count; The data type of the returned value must match the type of the method's declared return value. When a method is declared void, use the form of return that doesn't return a value. return;

PowerPoint Presentation: 

Java Programming 100 public static int inputInt (String prompt); returns an answer, a value which will be an int . Methods that return answers are called functions . Return type  Methods which do not return a value have the return type void .

Recursion: 

Java Programming 101 Recursion Simply put, recursion is when a function calls itself. That is, in the course of the function definition there is a call to that very same function. At first this may seem like a never ending loop. This might be true is some cases, but in practice we can check to see if a certain condition is true and in that case exit (return from) our method. The case in which we end our recursion is called a base case . Additionally, just as in a loop, we must change some value and incrementally advance closer to our base case .

Recursion: 

Java Programming 102 Recursion Every recursion should have the following characteristics. A simple base case which we have a solution for and a return value. A way of getting our problem closer to the base case, i.e. a way to chop out part of the problem to get a somewhat simpler problem. A recursive call which passes the simpler problem back into the method.

Factorial by Recursive Method: 

Factorial by Recursive Method class recursiveFact { public static long factorial( int num ) { if( num <= 1) return 1; else return num *factorial(num-1); } public static void main(){ System.out.println ("\f ");//used to clear screen int num =5; System.out.println ("Factorial= "+" of "+ num +" is"+ factorial ( num )); } } Java Programming 103 (RECURSIVE) Function Call factorial(5) factorial(4) factorial(3 ) factorial(2) factorial(1) return 1 return 2*1 = 2 return 3*2 = 6 return 4*6 = 24 return 5*24 = 120

Fibbonacci by Recursive Method: 

Fibbonacci by Recursive Method class recursiveFibbo { public static long fibonacci ( int num ) { if( num <= 1) return 1; else return fibonacci (num-1)+ fibonacci (num-2); } public static void main(){ System.out.println ("\f"); int num =5; for( int i=1;i<= num;i ++) System.out.println ("Term "+i+" of series is "+ fibonacci (i)); } } Java Programming 104 (RECURSIVE) Function Call

In-Built Methods-Mathematical: 

Java Programming 105 In-Built Methods-Mathematical Java has some built in mathematical functions for computing things like square roots. The mathematical functions are part of a class named "Math", and so they have compound names beginning with "Math", such as Math.sqrt for the square root function.  import java.lang.Math.*; no need to use Math with methods all the time.

In-Built Methods-Mathematical: 

Java Programming 106 In-Built Methods-Mathematical .abs computes the absolute value of x. Math.abs (x)=Absolute X . pow for computing x raised to the power y. Math.pow ( x,y ) = x y .sin , . cos , .tan Trigonometric function uses radians as arguments Math.sin (x );// x in radians.360º corresponds to radians  the value inside parentheses -- can be of any numeric type  Use Math.PI ( 3.141592653589793) to calculate value of .

In-Built Methods-Mathematical: 

In-Built Methods-Mathematical Important Math.toRadians Method Converts an angle from degrees to radians . angrad = angdeg * Math.PI /180 Math.toDegrees Method Converts an angle from radians angle to degrees. angdeg = angrad * 180/ Math.PI Java Programming 107

In-Built Methods-Mathematical: 

Java Programming 108 In-Built Methods-Mathematical .random returns a randomly chosen double in the range 0.0 <= Math.random () < 1.0. .round rounds x to the nearest integer. Math.round (3.76) = 4 . sqrt Returns the square root of a double value . cbrt Returns the cube root of a double value  the value inside parentheses -- can be of any numeric type

In-Built Methods-Mathematical: 

Java Programming 109 In-Built Methods-Mathematical .max Returns the greater of two values. Math.max ( int a, int b) .min Returns the smaller of two values. Math.min ( int a, int b) . rint Returns the double value that is closest in value to the argument. If two double values that are mathematical integers are equally close, the result is the integer value that is even . Math.rint (2.5)=2.0 & Math.rint (3.5)=4.0  the value inside parentheses -- can be of any numeric type

In-Built Methods-Mathematical: 

Java Programming 110 In-Built Methods-Mathematical .Ceil Returns the smallest value that is greater than or equal to the argument .floor Returns the largest value that is less than or equal to the argument  the value inside parentheses -- can be of any numeric type ceil floor static double ceil(double a); static double floor(double d);

In-Built Methods-Mathematical: 

Java Programming 111 In-Built Methods-Mathematical .log returns the log value of passed argument number with base e ( 2.718281828459045235360 ...) i.e. natural logarithm  the value inside parentheses -- can be of any numeric type  Our calculators allow us to use logarithms to base 10. These are called common logarithms ("log" on a calculator). We normally do not include the 10 when we write logarithms to base 10. We write log x to mean log 10 x Important 2.303 x log 10 (N) = log e (N )

In-Built Methods- Strings: 

Java Programming 112 In-Built Methods- Strings . charAt () . concat () . endsWith () .replace() . startsWith () .trim() . valueOf ()  Strings are a sequence of characters. In the Java programming language, strings are objects . The Java platform provides the String class to create and manipulate strings . The most direct way to create a string is to write: String name = “Indian”;

In-Built Methods- Strings: 

Java Programming 113 In-Built Methods- Strings .equals(String ) . equalsIgnoreCase () .substring( startPos , endPos ) .length() . indexOf () . lastindexOf () . compareTo (String) . toUpperCase () . toLowerCase ()

.charAt(): 

. charAt () . charAt () returns the character at the specified index. An index ranges from 0 to number of characters in the string minus 1. The first character of the sequence is at index 0, the next at index 1, and so on. String name=“Indian”;//LENGTH OF STRING=6 Char x= name.charAt (3 );//After execution value of x is a Java Programming 114  Index of I = 0  Index of n = 1  Index of d = 2  Index of i = 3  Index of a = 3  Index of n = 5

.concat(): 

. concat () . concat () concatenates the specified string to the end of this string. Examples : " cares". concat ("s") returns " caress“ “". concat ("s") returns "s " "cares". concat ("") returns " cares” " to". concat ("get"). concat ("her") returns "together" Java Programming 115

.endsWith(): 

. endsWith () Java Programming 116

.startsWith(): 

. startsWith () Java Programming 117

.replace(): 

.replace() Java Programming 118

.trim(): 

.trim () Java Programming 119

.valueOf(): 

. valueOf () Java Programming 120

In-Built Methods: 

Java Programming 121 In-Built Methods Arrays --------- .length

In-Built Methods: 

Java Programming 122 In-Built Methods (casts) -------- ( int ) ( double ) ( byte ) ( char ) (numeric + "") // to convert a numeric value to a String

PowerPoint Presentation: 

Java Programming 123 Java has extensive libraries of pre-existing classes for you to use and modify ( extend ). A full listing is in the docs directory of the Java SDK Class Libraries

PowerPoint Presentation: 

Java Programming 124 java.io - classes that enable file creation and reading and writing to the screen java.math - classes allowing arithmetic Class library examples

PowerPoint Presentation: 

Java Programming 125 java.net - classes allowing reference to URL's and network communication java.text - classes to allow you to "internationalize" your code java.util - utility classes Class Libraries

Garbage collection: 

Garbage collection responsible for freeing any memory that can be freed. This happens automatically during the lifetime of the Java program. programmer is freed from the burden of having to deallocate that memory themselves Java Programming 126

Code Security: 

Code Security Code security is attained in Java through the implementation of its Java Runtime Environment (JRE). JRE runs code compiled for a JVM and performs class loading ( through the class loader), code verification (through the bytecode verifier ) and finally code execution Java Programming 127