700 likes | 925 Views
** Java Certification Training: https://www.edureka.co/java-j2ee-soa-... ** <br>This Edureka PPT on u201cJava Tutorial For Beginnersu201d will give you a brief insight about Java and its various fundamental concepts along with their practical implementation. Through this tutorial, you will learn the following topics: <br>1. Introduction to Java <br>2. JVM vs JRE vs JDK <br>3. Java Fundamentals <br>4. Objects & Classes <br>5. Methods & Access Modifiers <br>6. Flow Of Control <br>7. Java Arrays
E N D
JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
Topics For Today’s Discussion Introduction To Java 01 02 JVM vs JRE vs JDK 03 Java Fundamentals 04 Objects & Classes 05 Methods & Access Modifiers Flow Of Control 06 Arrays 07 JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
Introduction to JAva
Introduction To Java Write Once Run Anywhere (WORA) High Level Programming Language Originally called OAK Father of Java is James Gosling Free and Open Source Software Released by Sun Microsystems in 1996 JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
Features Of Java Easy Robust Portable Platform Independent Distributed Object Oriented Secure Interpreted Multithreaded JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
JVM vs JRE vs JDK Java Virtual Machine ✓ JVM is an abstract machine that doesn’t exist physically ✓ Provides runtime environment to drive the Java Code or applications JVM ✓ It compiles the Java code into bytecode ✓ It is platform dependent JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
JVM vs JRE vs JDK Java Runtime Environment JRE ✓ JRE is the environment within which the JVM runs ✓ It contains a set of libraries + other files that JVM uses at runtime JVM ✓ Also called Java RTE JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
JVM vs JRE vs JDK JDK Java Development Kit JRE ✓ JDK is a software development environment which is used to develop Java applications and applets ✓ It contains Development Tools and JRE JVM JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
Java Objects 02 Behavior It is the functionality) of an object 01 State An real-world entity that It is the data (value) of an 03 Identity The object identity is typically implemented via a unique ID that is used internally by the JVM object has state and behaviour is known as an object CHARACTERISTICS JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
Java Classes A class is a group of objects which have common properties class <class_name>{ field; method; } JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
Java Classes Fields A class may contain Methods class <class_name>{ Constructors field; method; } Blocks Nested Class & Interface JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
Data Types Operators Variables Java Fundamentals
Java Fundamentals - Variables Variable refers to the name of reserved memory area Data Types Operators Variables 1 2 3 Local Variables Instance Variables Static Variables JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
Java Fundamentals – Data Types D ata Types Prim itive N on-Prim itive Data Types Operators Variables String B oolean N um eric A rray C haracter Integral Integer Floating Point byte short boolean char int long float double JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
Java Fundamentals - Operators ++X --X X++ X-- +X –X ! ~ + - * ? % && || ? : Data Types Operators = += -= *= /= %= &= ^= |= <<= >>= >>>= Variables < > <= >= == != ^ << >> >>> & | 1 2 3 4 5 6 7 8 Arithmetic Arithmetic Operators Operators Bitwise Bitwise Operators Operators Logical Logical Operators Operators Relational Relational Operators Operators Ternary Ternary Operators Operators Assignment Assignment Operators Operators Unary Unary Operators Operators Shift Shift Operators Operators JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
Java Methods
Java Methods A method is a set of code that is grouped together to perform a specific operation A method must be written inside a class Each method has its own signature Java provides two types of methods Pre Defined or Standard Library Methods User Defined Methods JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
Java User Defined Methods To use a method, you need to perform two steps: Method Initialization Method Invocation JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
Java Methods modifier returnType nameOfMethod (Parameter List) { // method body } Method Initialization ✓ A method can be parameterized or non-parameterized Method Invocation ✓ Method definition consists of a method header and a method body ✓ You can Overload Method i.e. Provide same name to more than one method but their data type or parameter list must be different JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
Java Methods methodName() methodName(parameter1, parameter2...) Method Initialization ✓ To use a method it needs to be invoked or called Method Invocation ✓ When a program invokes a method, the program control gets transferred to the called method ✓ A method can be called in two ways: 1. Call by Value 2. Call by Reference JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
Access Modifiers
Access Modifiers Access modifiers helps to restrict the scope of a class, constructor , variable , method or data member Default Public Private Protected JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
Access Modifiers Protected Default Public Private Same class Yes Yes Yes Yes Same Package subclass Yes No Yes Yes Same Package non- subclass Yes No Yes Yes Different package subclass No No Yes Yes Different package non- subclass No No No Yes JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
My First Java Program
My First Java Program class Demo{ public static void main(String args[]){ public static void main(String args[]) System.out.println("Hello Edureka!!!"); } } JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
My First Java Program public static void main String args[] public static void main(String args[]) JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
My First Java Program public static void main(String args[]) public It is the access modifier of the main method static It is a keyword which identifies the class related thing void It is used to define the Return Type of the Method It is the name of the method that is searched by JVM as a starting point for an application with a particular signature only main It is the parameter to the main Method where the argument name could be anything String args[] NOTE: main() in Java is the most important method as it is the entry point of any java program JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
Do While While For Iterative Statements
Iterative Statements – For Loop It is a control structure that allows us to repeat certain operations by incrementing and evaluating a loop counter Initialization START Do While While For False Increment /Decrement Condition END True Statement JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
Iterative Statements – For Loop Syntax for(initialization; condition; incr/dcr) Do While { While For code block; } Initialization START Increment /Decrement False Condition END True Statement JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
Iterative Statements – While Loop It is a control structure that allows us to specify that a certain statement is to be executed repetitively until the loop condition is false START Do While While For False Condition END True Statement JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
Iterative Statements – While Loop Syntax while (boolean condition) Do While { While loop statements... For } START False Condition END True Statement JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
Iterative Statements – Do While Loop It is a control structure that allows code to be executed repeatedly based on a given Boolean condition and tests the condition before executing the loop body Statement START Do While While For True False Condition END JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
Iterative Statements – Do While Loop Syntax Do While START Statement While do{ For //code to be executed True } False while(condition); Condition END JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
Switch If-Else If Conditional Statements
Conditional Statements - If It is the simplest selection statement in the Java language that checks the condition and executes the loop if condition is true Switch If-Else If If Nested If JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
Conditional Statements - If If is the most simple decision making statement that decides whether a certain statement or block of statements will be executed or not Test Switch START If-Else Expression If If True False Nested If Body of If Statement below If END JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
Conditional Statements - If Syntax Switch if(condition) If-Else If { If //Statements to execute if condition is true Nested If } JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
Conditional Statements - If It is an if statement or an if-else statement within an if statement Nested Test Expression Test START Expression Switch If-Else If If False True True Body of Nested If Body of If Body of If Nested If Statement below If END JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
Conditional Statements - If Syntax if (condition1) { Switch If-Else // Executes when condition1 is true If if (condition2) If { // Executes when condition2 is true Nested If } } JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
Conditional Statements - If Else It is an upgraded if statement that tests the condition and if the condition is false then ‘else’ statement is executed Switch If-Else If If-Else-If Ladder If-Else JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
Conditional Statements - If Else It tests the condition and if the condition is false then ‘else’ statement is executed Test START Expression Switch If-Else If If-Else True False If-Else-If Ladder Body of If Body of Else Statement below If END JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
Conditional Statements - If Else Syntax if (condition) { //Executes this block if condition is Switch If-Else true If If-Else } else If-Else-If Ladder { //Executes this block if condition is false } JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
Conditional Statements - If Else If-else-if ladder allows the user to use many if else statement within a loop and in case one of the condition holds true the rest of the loops is bypassed Test True START Expression Statement 1 Switch If-Else False If Test If-Else True Statement 2 Expression If-Else-If Ladder False Test True Statement 3 Expression Body of Else Statement below If-else-if JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training
Conditional Statements - If Else Syntax if (condition) { statement; } else if (condition) { statement; } . . else statement; Switch If-Else If If-Else If-Else-If Ladder JAVA CERTIFICATION TRAINING www.edureka.co/java-j2ee-soa-training