600 likes | 1.11k Views
This Edureka Java Tutorial will help you in understanding the various fundamentals of Java in detail with examples. Below are the topics covered in this tutorial: <br><br>1) Introduction to Java <br>2) Why learn Java? <br>3) Features of Java <br>4) How does Java work? <br>5) Data types in Java <br>6) Operators in Java <br>7) Control Statements in Java <br>8) Arrays in Java <br>9) Object Oriented Concepts in Java
E N D
` EDUREKA JAVA CERTIFICATION TRAINING What is Hadoop? https://www.edureka.co/java-j2ee-soa-training
Agenda For Today ➢ Java Introduction ➢ Why Learn Java? ➢ Features of Java ➢ Java Development Kit ➢ How does Java work? ` ➢ Data Types in Java ➢ Operators in Java ➢ Control Statements ➢ Array in Java ➢ Object Oriented Concepts in Java EDUREKA JAVA CERTIFICATION TRAINING https://www.edureka.co/java-j2ee-soa-training
Java Introduction ` EDUREKA JAVA CERTIFICATION TRAINING https://www.edureka.co/java-j2ee-soa-training
Java Introduction ➢ Java was created by James Gosling in 1995 for Sun Microsystems. ➢ Java is a platform independent programming language that follows the logic of “Write once, Run anywhere”. Concurrent ` Object Oriented Class Based EDUREKA JAVA CERTIFICATION TRAINING https://www.edureka.co/java-j2ee-soa-training
Why Learn Java? Below is the TIOBE Programming index for all the present trending programming languages: ` EDUREKA JAVA CERTIFICATION TRAINING https://www.edureka.co/java-j2ee-soa-training
Why Learn Java? Below are some of the domains that make use of Java: Financial Services Retail Android ` Big Data Banking Stock market Information Technology Scientific Research EDUREKA JAVA CERTIFICATION TRAINING https://www.edureka.co/java-j2ee-soa-training
Why Learn Java? Below are some of the technologies that make use of Java as an essential core of their functionalities: Continuous Testing Web Development ` Android Framework Big Data EDUREKA JAVA CERTIFICATION TRAINING https://www.edureka.co/java-j2ee-soa-training
Features of Java Secure Simple Portable ` Dynamic Object-oriented Distributed Robust High performance EDUREKA JAVA CERTIFICATION TRAINING https://www.edureka.co/java-j2ee-soa-training
Features of Java Simple Java was designed to be easy for professional programmer to learn and use effectively. ` Portable Applications written on one platform of Java can be easily ported to another platform as it is platform independent. EDUREKA JAVA CERTIFICATION TRAINING https://www.edureka.co/java-j2ee-soa-training
Features of Java Object-oriented Java is an object oriented programming language. Everything is considered to be an “object” and all operations are performed using these objects. {OOPS} {OOPS} ` Secure Java does not use explicit pointer and runs its programs inside the sandbox to prevents any activities from untrusted sources. EDUREKA JAVA CERTIFICATION TRAINING https://www.edureka.co/java-j2ee-soa-training
Features of Java Distributed Java has a feature called Remote Method Invocation (RMI) using which a program can invoke method of another program across a network and get the output. ` Dynamic Java programs carry with them substantial amounts of run- time type information that is used to verify and resolve accesses to objects at run time. EDUREKA JAVA CERTIFICATION TRAINING https://www.edureka.co/java-j2ee-soa-training
Features of Java Robust ➢ Java checks the code during the compilation time and run time also. ➢ Java completely takes care of memory allocation and releasing, which makes the Java program more robust. ` High performance Java achieves high performance through the use of bytecode which can easily translated into native machine code. EDUREKA JAVA CERTIFICATION TRAINING https://www.edureka.co/java-j2ee-soa-training
Java Development Kit Development Tools JVM ` Java Class Libraries Other Files JRE JDK EDUREKA JAVA CERTIFICATION TRAINING https://www.edureka.co/java-j2ee-soa-training
How does Java work? Compile-time Environment Run-time Environment Class Loader Bytecode Verifier Java Class Libraries Java Source (.java) Just in Time Compiler Java Interpreter Java Compiler ` Java Bytecodes move locally or through network Java Virtual Machine Runtime System Operating System Java Bytecode (.class) Hardware EDUREKA JAVA CERTIFICATION TRAINING https://www.edureka.co/java-j2ee-soa-training
Installation ` EDUREKA JAVA CERTIFICATION TRAINING https://www.edureka.co/java-j2ee-soa-training
Java Installation Go to http://www.oracle.com/technetw ork/java/javase/downloads 1 ` Download Java Platform(JDK) version 8 update 121 and install on your Windows system 2 EDUREKA JAVA CERTIFICATION TRAINING https://www.edureka.co/java-j2ee-soa-training
Java Installation To set the permanent path of JDK in your system: 1 1. Begin by going to My Computer Properties. 2 2. Click on Advanced system setting. ` 3. Click on Environment Variables option 4 4. Select Path variable to edit 5. Enter the path to bin folder inside JDK installed on your system.( Default path is C:\Program Files\Java\jdk1.8.0_121\bin ) 5 3 EDUREKA JAVA CERTIFICATION TRAINING https://www.edureka.co/java-j2ee-soa-training
Eclipse IDE Installation Go to www.eclipse.org 1 Download Eclipse Neon installer and install on your Windows system 2 ` EDUREKA JAVA CERTIFICATION TRAINING https://www.edureka.co/java-j2ee-soa-training
Data Types in Java Primitive Data Type Integer Float Character Boolean bool (1 byte, but makes use of 1 bit of it) byte (1 byte) char (2 byte) float (4 bytes) ` char ch = ‘X’ long (8 bytes) double (8 bytes) boolean b = true float num = 56851.3285 short (2 bytes) int (4 bytes) int num = 56 EDUREKA JAVA CERTIFICATION TRAINING https://www.edureka.co/java-j2ee-soa-training
Data Types in Java John owns a Retail Department store. John needs to create a bill with the following fields present: ➢ Invoice ID ➢ Product ID ➢ Product Cost ➢ Quantity ` ➢ Discount ➢ Total Price ➢ Feedback Provided ? John has no knowledge about the data types in java, Can you help John ? EDUREKA JAVA CERTIFICATION TRAINING https://www.edureka.co/java-j2ee-soa-training
Data Types in Java John owns a Retail Department store. John needs to create a bill with the following fields present: ➢ Invoice ID - Integer ➢ Product ID - Integer ➢ Product Cost - Double ➢ Quantity - Integer ` ➢ Discount - Double ➢ Total Price - Double ➢ Feedback Provided ? - Boolean EDUREKA JAVA CERTIFICATION TRAINING https://www.edureka.co/java-j2ee-soa-training
Data Operations in Java Data Operations Arithmetic Operators Logical Operators Unary operators Relational operators ` < Less than <= Less than or equal to > Greater than >= Greater than or equal to != Not equal to == Equals ++ Increment operator -- Decrement operator + Addition - Subtraction * Multiplication / Division % Modulus && And || Or ! Not EDUREKA JAVA CERTIFICATION TRAINING https://www.edureka.co/java-j2ee-soa-training
Data Operations in Java Let us assume the following values for the variables: ➢ Num1 = 10 ➢ Num2 = 15 ➢ Num3 = 25 ➢ Num4 = true Operation Solution ` (Num1 + Num2) – Num3 / 5 20 Num1++ 11 Num3 >= Num1 + Num2 True Num2 == Num1 False (Num2 < Num3) && (Num1 > Num3) False !Num4 False EDUREKA JAVA CERTIFICATION TRAINING https://www.edureka.co/java-j2ee-soa-training
Data Operations in Java Mathew has come to John’s store to purchase a few products. Below are the items Mathew wishes to purchase : Product Item A Item B Item C Quantity 2 1 3 Below are the cost of the products: ` Product Item A Item B Item C Cost 200 75 500 At the time Mathew visited the store, there was a 10% discount on all product. Finally a service tax of 5% is applicable on all products. Can you help John compute the amount Mathew has to pay ? EDUREKA JAVA CERTIFICATION TRAINING https://www.edureka.co/java-j2ee-soa-training
Control Statement Control Statements ` Jump Selection Statements Iteration Statements Statements break If.. else Switch.. Case continue while for do .. While EDUREKA JAVA CERTIFICATION TRAINING https://www.edureka.co/java-j2ee-soa-training
Control Statement Control Statement 1. If statement START Syntax: Selection Statements If it is raining if (condition): statements 1 … else: statements 2 … Iteration Statements ` TRUE Jump Statements Take an Umbrella FALSE Go Play Football EDUREKA JAVA CERTIFICATION TRAINING https://www.edureka.co/java-j2ee-soa-training
Control Statement Control Statement 2. Switch statement START Syntax: Outcome of Toss Selection Statements switch (expression) { case value1: Statement1 Iteration Statements ` TRUE Head Tom Wins break; Jump Statements FALSE case value2: Statement2 TRUE Adam Wins Tails break; FALSE . . . Invalid input default EDUREKA JAVA CERTIFICATION TRAINING https://www.edureka.co/java-j2ee-soa-training
Control Statement LOOPS REPEAT ACTIONS SO YOU DON’T HAVE TO ... Execute once and then repeats things until loop condition is true Do While Repeat things until the loop condition is true While Repeat things till the given number of times For www.edureka.co/python EDUREKA PYTHON CERTIFICATION TRAINING
Control Statement 3. do while statement Control Statement START Syntax: Selection Statements EXECUTE BLOCK do { Iteration Statements ` repeat Jump Statements statements… } while (condition is True) FALSE CHECK CONDITION TRUE EXIT LOOP EDUREKA JAVA CERTIFICATION TRAINING https://www.edureka.co/java-j2ee-soa-training
Control Statement 4. while statement Control Statement START Syntax: while (condition is True) { statements… } Selection Statements FALSE CHECK CONDITION Iteration Statements ` Jump Statements TRUE repeat EXIT LOOP EXECUTE BLOCK EDUREKA JAVA CERTIFICATION TRAINING https://www.edureka.co/java-j2ee-soa-training
Control Statement START 5. for statement Control Statement Initialization Selection Statements Syntax: for(initialization; condition; iteration) { statements… } FALSE Check condition Iteration Statements ` Exit loop TRUE Jump Statements repeat Execute Statements Iteration EDUREKA JAVA CERTIFICATION TRAINING https://www.edureka.co/java-j2ee-soa-training
Control Statement START 6. break Control Statement Selection Statements FALSE Syntax: Check Loop Condition break; Iteration Statements ` TRUE EXIT LOOP repeat Jump Statements TRUE Check Break Condition FALSE EXIT LOOP Execute Block EDUREKA JAVA CERTIFICATION TRAINING https://www.edureka.co/java-j2ee-soa-training
Control Statement 7. continue Control Statement START Selection Statements FALSE Syntax: Check Loop Condition continue; Iteration Statements ` TRUE EXIT LOOP repeat Execute Block 1 Jump Statements Check Continue Condition TRUE FALSE Execute Block 2 EDUREKA JAVA CERTIFICATION TRAINING https://www.edureka.co/java-j2ee-soa-training
Control Statement Marry is a school teacher. She conducted the final exam for the year. The exam included the following subject: Computer Science Mathematics Chemistry Physics English Since there are multiple students, she wanted to create an automated system that will take the marks for these subjects and provide a grade for the final score. Below is the grade distribution : Can you help me? ` Percentage Below 40 40-59 60-79 80-89 90+ Grade Poor Average Good Very Good Excellent EDUREKA JAVA CERTIFICATION TRAINING https://www.edureka.co/java-j2ee-soa-training
Array In Java Can you help me again? Remember John ? Well now he has a great business running. John now has a new challenge, he has 15 invoice number that he wants to store the corresponding amount together but he doesn’t want to store them using different number. ` EDUREKA JAVA CERTIFICATION TRAINING https://www.edureka.co/java-j2ee-soa-training
Array In Java An array is a data structure which holds the sequential elements of the same type. Arrays of any type can be created and may have one or more dimensions. 0 1 2 3 4 E.g: array index 4 is holding a value of 200 ` Index 126 32 230 21 200 Value Each index in the array holds a value. EDUREKA JAVA CERTIFICATION TRAINING https://www.edureka.co/java-j2ee-soa-training
Array In Java Arrays can be of 2 types: Multi Dimensional Array Single Dimensional Array Initialization: int table[][] = new int[4][5]; Initialization: int a[] = new int[12] ` Index in Y dimension 0 1 2 3 4 0 1 2 3 Index in X dimension Height =4 Width = 5 EDUREKA JAVA CERTIFICATION TRAINING https://www.edureka.co/java-j2ee-soa-training
Class and Objects ➢ Java is an object oriented and class based programming language. ➢ Object is simply a collection of data (variables) and methods (functions) that act on those data. ➢ Class is a blueprint for the object. ` Blueprint of a house can be considered as a class With the Same blueprint we can create several houses and these can be considered as objects EDUREKA JAVA CERTIFICATION TRAINING https://www.edureka.co/java-j2ee-soa-training
Inheritance ➢Inheritance is a mechanism through which one object acquires all the properties and behaviors of parent object. ➢To avoid code redundancy, a derived class is developed upon a base class to achieve code reusability. Super Class ` Animals Child Class Reptiles Mammals Birds Amphibians EDUREKA JAVA CERTIFICATION TRAINING https://www.edureka.co/java-j2ee-soa-training
Encapsulation ➢Encapsulation is the mechanism that binds together code and the data it manipulates together. ➢In encapsulation, the variables of a class will be hidden from other classes, and can be accessed only through the methods of their current class. Encapsulation ` Class Methods Variable EDUREKA JAVA CERTIFICATION TRAINING https://www.edureka.co/java-j2ee-soa-training
Polymorphism ➢Polymorphism is the ability of a variable, function or object to take on multiple forms. ➢Overloading of functions is achieved by the usage of polymorphism. Everyone, Draw a shape. ` EDUREKA JAVA CERTIFICATION TRAINING https://www.edureka.co/java-j2ee-soa-training