0% found this document useful (0 votes)
67 views

1 Java Notes Full PDF

Uploaded by

shivashan2207
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
67 views

1 Java Notes Full PDF

Uploaded by

shivashan2207
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 158
DAY-1 JAVA HISTORY Father of Java James Gosling. It was developed by James Gosling 1991 with a small team called Green Team. Initially it was designed for electronic appliances like set-top boxes. Firstly, it was called Greentalk 1991, Then it was renamed to OAK. The name Oak was used by Gosling after an oak tree that remained outside his office. Trademark issues with Oak Technologies JAVA, DNA, SILK, RUBY Launch Name is Java Initially developed by James Gosling at Sun Microsystems and released in 1995. Currently Owned by Oracle in 2010 WHAT IS JAVA? It is a Simple Programming Language. It let programmers write once, run anywhere (WORA) In Java, Writing, Compiling and Debugging is easy Compiling - Converting Source code to Byte Code Debugging - to find out the errors FEATURES . Platform Independent - Java Code can be executed on multiple platforms. Such as Windows, Linux, Sun Solaris, Mac OS. Open Source ( Free of Cost) Secured - Java Programs run inside a Virtual Machine Sandbox. So it does not allow Scam, Virus popups. * Robust (Strong) - Java provides automatic garbage collection which runs on the Java Virtual Machine to get rid of objects which are not being used by a Java application anymore. + Due to JVM it avoids Security Problems. * Portable - Java is portable because it facilitates you to carry the Java bytecode to any platform (WORA). © Multi-Threading - More than one task can be completed at one time (note pad, note pad, note pad) © Multi-Tasking - Different task can be completed at a time (notepad, chrome, opera) JAVA ARCHITECTURE * IDK (JAVA DEVELOPMENT KIT) 1, JDK contains tools required to write Java programs 2. It includes a compiler, Java application launcher. 3. Compiler converts code written in Java into byte code. 4, Java application launcher opens a JRE, loads the necessary class, and executes its main method. «¢ JVM (JAVA VIRTUAL MACHINE’ 1. It converts Java bytecode into machine language. 2. JVM is a part of the Java Run Environment (JRE). 3. In other programming languages, the compiler produces machine code for a particular system. However, the Java compiler produces code for a Virtual Machine known as Java Virtual Machine. 4. JVM provides a platform-independent way of executing Java source code. © JRE (JAVA RUNTIME ENVIRONMENT) i ; ; 2. It does not include any tool for Java development like a debugger, compiler, etc. CODING STANDARDS: Pascal standard- Every First Letter Of Word Should Be In Uppercase/Capital. . in Proj me, Class Nami Camel standard - Except first word remaining words first letter mu: Capital « Used in method Name, object Name, variable Name. ro | Haha | om JAVACODETO aT Neug peneiets use) INTERPRET JAVA it P os = > Tia Ta JAVA PROGRAM EXECUTION a — aa 5 & g = | = Ea Development Compile ees e JavaQueries.com IDE: Integrated Development Environment IDE is software application that provides facilities to computer programmers for software development. Eclipse - IDE Installation of Java and Eclipse IDE 1) Install JDK------> Standard Version 1.8 2) Install Eclipse IDE first install JDK than install Eclipse IDE, than only the Eclipse will Integrated with JDK. Structure: 1. Project 2. package 3. Class 4, methods 5. object Window- >Show View- Package Explorer In package Explorer we maintain Our Project File------> New ------> Java Project Project Name : Pascal Click Finish Project: © JRE * src(source) Steps to create a package : Right click on sr Package name : com.tsc.prime Click on Finish Steps to create a Class Right Click on package-------> New------> Class Class Name : Pascal Standards Finish Class File extension: java main method > Type main Keyword >ctrl+space System.out.printin(); > Type syso Keyword~ctrl+space Use (semicolon) ; to end the line ctrl+shift+f------------> for allignment Object Ori ip ing S Method of Implementation of our Program are organized in the form of * Class * Method © Object Combination of Methods and Object. Method: Set of actions to be Performed. © Itis instance of the Class. © Ithelps to invoke the methods. Hin We must Create a object inside the main method. Syntax to create obje Classname objName = new Classname(); To invoke method: objName.methodName(); --> command line( //Java Compiler doesn’t invoke that line } Shortcuts Access Modifiers / Access Specifiers : Access Modifiers -------------> control the access level Access Modifiers Types © Public * Private * Protected * Default (No Keyword ) At Class Level Public Keyword at Class level - Yes Private Keyword at Class level - No Protected Keyword at Class level - No Default( No Keyword ) at Class level - Yes At Method Level Public Keyword at Method level - Yes Private Keyword at Method level - Yes Protected Keyword at Method level - Yes Default( No Keyword ) at Method level - Yes Access Modifier within class within package Private Default Protected Public plain old java object Inheritance: Accessing One Class Property into another class with the help of "extends" keyword. Purpose of Inheritance : « toreduce the memory wastage * and to reduce the object creation DAY-5 Inheritance : Accessing One Class Property into another class with the help of "extends" keyword. Purpose of Inheritance : * toreduce the memory wastage * and to reduce the object creation In Java, there are two classes: 1, Parent class ( Super or Base class) 2. Child class (Subclass or Derived class) * A class which inherits the properties is known as Child Class whereas a class whose properties are inherited is known as Parent class 'ypes of Inheritance ¢ Single Multilevel Hierarchical Multiple Hybrid In single inheritance, one class inherits the properties of another, Class A 4 i Class B extends A { } Here, Class A is your parent class and Class B is your child class which inherits the properties and behavior of the parent class. Multilevel Inheritance When a class is derived from a class which is also derived from another class, i.e. a class having more than one parent class but at different levels, such type of inheritance is called Multilevel Inheritance. ass At } Class 8 extends A{ } Class C extends 8{ If we talk about the flowchart, class B inherits the properties and behavior of class A and class C inherits the properties of class B. Here A is the parent class for B and class B is the parent class for C. So in this case class C implicitly inherits the properties and methods of class A along with Class B. That's what is multilevel inheritance Hi hical Inheri When a class has more than one child classes (sub classes) or in other words, more than one child classes have the same parent class, then such kind of inheritance is known as hierarchical P Class B extends A{ } Class ¢ extends Af My If we talk about the flowchart, Class B and C are the child classes which are inheriting from the parent class i.e Class A Multiple Inheritance In this inheritance, a derived class is created from more than one base class. This inheritance is not supported Java Language. It can be achieved through Interfaces. In the given example, class D inherits the properties and behavior of class B and class C at the same level. So, here B and Class C both are the parent classes for Class D. This is a combination of more than one inheritance. Hence, it may be a combination of Multilevel and Multiple inheritance or Hierarchical and Multilevel inheritance or Hierarchical, Multilevel and Multiple inheritances. In Hybrid inheritance a combination of multiple inheritance and multilevel inheritance is not possible. Since multiple inheritance is not supported in Java as it leads to ambiguity, so this type of inheritance can only be achieved through the use of the interfaces. If we talk about the flowchart, class A is a parent class for class B and C, whereas Class B and C are the parent class of D which is the only child class of BandC. DAY-6 What is Data Type? It specifies which type of value a variable has and what type of mathematical, relational or logical operations can be applied. What is a Variable? * Avariable is a container which holds value. Every variable is assigned a data type which designates the type and quantity of value it can hold. In order to use a variable in a program you to need to perform 2 steps ~ Variable Declaration - Variable Initialization Variable Declaration Variable initialization VariableName — aie V V7 Pi age = 20; int age; 8 ' 3 Container named age holdinga value 20 VariableName int variable Declarationand Initialization DataType Types: 1) Primitive 2) Non- Primitive Primitive 1. A variable can store only one value. 2. predefined data type. byte, short, int, long : accepts whole numbers float, double : accepts decimal numbers boolean b = true char : accepts any single character / special character / numeric value enclosed with in single quotes ('6'). boolean: true / false Note: 1 byte = 8 bit Range of formula: -2(n-1)to 2*(n-1)-1 n=bit n=8 -2(8-1) to 24(8-1)-1 -128 to 127 -------> byte Range Datatype Declaration: Syntax: DataType refName = value ; Non-Primitiv: 1.A variable can store multiple value. 2.its not a predefined datatype. eg: String and Array DAY-7 One task can be performed in many forms Poly -> Many Morphism -> Forms Types * Method Overloading/ Compile-Time Polymorphism/ Static Binding * Method Overriding/ Run-Time Polymorphism/ Dynamic Binding Method Overloading In same class method names will be same but arguments and parameters will be different. Depends upon * Datatype * Datatype Order © Datatype Count Overloading add(int x, int y) add(int x, int y, int z) add(double x, double y) add(double x, double y, double z) add (int x, double y) add (double y, int x) Task: Student Firstname, Lastname Student Age Student Gender Student Address along with pincode Student Father name and his initial Student Bank Account Number Method name must be student_Info Class name : Student_Details Method Overriding In different class method names, arguments and parameters will be same. * We have two classes © One is Parent and another is child * But method names and argument names are same © Itwe invoke same method in child it will invoke @Override Annotation * By using super keyword we can invoke Parent class method © Itis also known as runtime polymorphism/ Dynamic Binding. extends Converting one datatype to another datatype is called Type Casting Types: © Widening © Narrowing Widening: From lower datatype to higher datatype Narrowing: From higher datatype to lower datatype Class Casting / Object Casting. © Upcasting © Downcasting Upcasting: ParentClassName objName = new ChildClassName(); * Accessing Child Class Method in Parent Class with the help of ParentClassName objName = new ChildClassName(); ¢ It will restrict to invoke Child Class own methods. « But we will invoke easily override methods. Downcasting: * Accessing parent class method in child class with the help of ChildClassName objName = new ParentClassName(); ---> Trying DownCasting (Add to Cast) ChildClassName objName = (ChildClassName) new ParentClass(); > Downcasting ° Ifwe try to invoke Parent Class Method with help of downcasting it will throw ClassCastException at runtime. So DownCasting is not possible in java classes. * Hiding the implementation Part Types: © Partial Abstraction(Abstract Class) * Fully Abstraction(Interface) Partial Abstraction: * Itsupports abstract methods and non-abstract methods * Abstract method doesn’t have method body and implementation part. It contains only signature part. © We should use public abstract keyword in class level and method level. * Abstract methods must be overridden © We cannot create object for abstract class. We cannot create an object for abstract class. But with the help of upcasting we will create an instance for abstract class and invoke class methods and override methods, ¢ But it will not invoke child class own methods When overriding abstract methods super keyword doesn’t get implemented * Abstract methods must be overridden. DAY - 11 - Interface INTERFACE (Fully Abstraction): * Itcontains only Abstract Methods. © Abstract method doesn’t have method body and implementation part. It contains only signature part. * public abstract keyword is default in Interface. * Abstract methods must be overridden © We cannot create object for Interface but with the help of upcasting we can create an instance and call the overrided methods. But it will not invoke child class own methods. * We must use implements keyword to access methods from interface NOT! © When overriding abstract methods super keyword doesn't get implemented Task: Task 4: Timplements 1 Timplements ¢ Timplements A Textends I Textends C Textends A C implements I C implements C C implements A Cextends I Cextends C Cextends A A implements 1 A implements C A implements A Aextends I Aextends C Aextends A Description: Find the answer for above questions(¥/N) A-abstract class C-class T-interface DAY-12-VARIABLES VARIABLES: ¢ Itis a container that holds a value. Variable Declaration Variable Initialization Variable Name Cneant value Data Type age = 20; int age; - Container named age VariableName holdinga value 20 int variable Declaration and Initialization SYNTAX: © Datatype variableName = value; Types: * Local Variable * Class Variable / Instance Variable / Non-Static Variable * Static Variable ¢ Final Variable / Constant Variable * Local Variable must be inside the method. //Location © We must initialize the local variable. //Initialization © Its lifecycle will be throughout the method. //Lifecycle * Local variable value can be changed. Class Variabl * Class variable must be inside the class outside the method. © Initialization is not mandatory. © Ifwe not initialize, the default value of given datatype will be printed. © Its lifecycle will be throughout the class. * Class variable value can be easily changed. NOTE: ¢ IfLocal and Class variable reference name are same, then the priority goes to local variable inside the method. © Ifwe call the class variable inside the main method we must create an object and invoke the variable. ° Eg: int a= 10; 0; Here, = is assigning operator. OPERATORS: -o ific sym f ific Onerati Types: * Arithmetic * Logical © Comparison * String Arithmetic Operators: * Arithmetic operators are used in mathematical expressions in the same way that they are used in algebra © Following are the types of Arithmetic Operator. + Addition : Subtraction * Multiplication I Division Arithmetic % Modulus Increment and then return value Return value and then increment | X=3; X++ Decrement and then retum value Return value and then decrement | X=3; X-- + alelalsle|plalela Note: «Here Addition, Subtraction, Multiplication and Division are basic arithmetic operators. * The operands of arithmetic operators must be of numeric type. © When division operator is applied to an integer type, there will be no fractional component attached to the result. MODULUS OPERATOR: * The modulus operator % returns the remainder of division operation. © Itcan be applied to both floating point types and integer types. ARITMETIC ASSIGNMENT OPERATOR: © It isan special operator that can be used to combine an arithmetic operation with an assignment. © Eg: asat4; at=4; INCREMENT AND DECREMENT OPERATOR: * The ++ and ~are java's increment and decrement operators. © These operators are unique that they can appear in both post form and prefix form. Logical Operators: © The logical Operators give Boolean result, Logical I the operand is false Logical “and” evaluates to true | 3>2 && hk when both operands are true 5>3 Cd i Logical “or” evaluates to true when either operand is true DIDS | Toe ' Logical “not” evaluates to true if 4122 Te Relational or C ison 0 . © The relational operators determine the relation one operator has to others, * Italso give Boolean results. Equal 5== False Not equal 6!=4 True Compatison < Less than 362 False P <=__| Less than or equal 5<=2 False > __| Greater than 43 True >= __| Greater than or equal 4o=4 True String Operator: * Itjoins two strings -----> Concatenation ‘Swing + | Concatenation(join two strings | “A”¥"BC” | ABC together) Static Variable: * Located Inside the class, Outside the method with static keyword. Eg: static datatype refname = value; © Initialization is not mandatory. But if we not initialize the default value of given datatype will be printed. * Its lifecycle will be throughout the class. * Static variable value can be easily changed. © We can invoke Static variable directly. Note: © If static variable and local variable has same reference name then the priority goes to local variable inside the method. « Local variable cannot be static. Final Variable: * Located inside the class, outside the method with final keyword. Eg: final datatype refName = value; © Initialization is mandatory. * Its lifecycle will be throughout the class. © Final variable value cannot be changed. © Itis also known as constant variable, © Using object we can invoke final variable. Note: © If Final variable and local variable has same reference name then the priority goes to local variable inside the method. * Local variable can be final. Error shown before running java application Run-Time Error: Error shown after running java application in console window. id K rd: * Itallows us to create method that does not return a value ( does not give credit to anyone ) * Note: It can be used only for methods Return Keyword: «Return keyword has a specific meaning in java compiler. © Itis used on inside a method to specify that method will return certain value to calling method ( Gives credit) Return Type Shortcut: © First press ctrl+2, then press L. Scanner: ¢ Itisa Class * It is used to read data from user at runtime. © Itis present in java.util package Syntax: Scanner refName = new Scanner(System.in); * Scanner => Class System => Class * in => Static Variable in => input stream (gets input from the user) out => output stream (prints output to the user) byte nextByte() short nextShort() int nextInt() long nextLong() float nextFloat() double nextDouble() Boolean nextBoolean() String _next() ==> Don’t get values after space nextLine() == Get values after space DAY-16 Keywords Static: Static is a keyword. It can be used in three levels 1, Method 2. Variables 3. Block Once we declare the method or variable or block static, then without creating an object we can easily invoke them. If we try to invoke static method from outside class without extends, then we use 1. ClassName.methodName(); 2. ClassName.variableName; If we try to invoke the static method from outside class with extends keyword we can directly call the variable or method inside the main method. Note: Static methods cannot be overridden but can be overloaded. Final: Final is a keyword. It can be used in three levels 1, Class > Cannot be inherited 2. Methods Cannot be overridden but can be overloaded 3. Variables > Variable value cannot be changed Eg for final Class : System Super: © super keyword is used to refer immediate parent class. © this keyword is used to refer immediate current class. new: © Itisa keyword * Itallocates memory « With the help of new keyword we will invoke the constructor. DAY-17 Control Statements Control Statements: ¢ Iteration Statements * Selection Statements © Jump Statements Iteration ‘ments: © Forloop * While loop * Do while loop for loop: © In for loop we can execute a sequence of statements multiple time, where we can manage the loop variable. * Basically we have 3 operations here: initialization, condition and iteration. for (initialization; condition; iteration){ // for loop body Order of Execution: * Initialization i * Condition 1/2 * Loop Body 113 © Iteration 1/4 * Condition 1/2 * Loop Body 113 © Iteration .. 1/4 Flow Chart: START Check condition Execute Statements In this flowchart, the code will respond in the following steps: 1, First of all, it will enter the loop where it checks the initialization value condition. 2. Next, if the condition is true, the statements in loop body will be executed. 3. Then it will go for iteration and so on. 3. If the condition is false, it directly exits the loop. System.out.print(); ® After printing the data the cursor will be in same line System.out.printin(); ® After printing the data the cursor will move to next line. Nested for loop: * A for loop inside another for loop is known as nested for loop. SYNTAX: for(initialization; condition; iteration){ //outer loop for(initialization; condition; iteration){ —_//inner loop While Loop It checks condition at entry level * Repeat a group of statements while a given condition is true, It tests the condition before executing the loop body. SYNTAX: / (initialization while() { Statement; //condition Iteration; 3 FLOWCHART: START 7 ams i CONDITION XT LOOP EXECUTE BLOCK In this flowchart, the code will respond in the following steps: 1. First of all, it will enter the loop where it checks the condition. 2. If it’s true, it will execute the set of code and repeat the process. 3. Ifit’s False, it will directly exit the loop. * Itchecks condition during exit. © Itis like a while statement, but it tests the condition at the end of the loop body. Also, it will executes the statement at least once. SYNTAX: /finitialization; dof statement; iteration; } whileQ); FLOWCHART: [ _Y EXECUTE BLOCK CHECK CONDITION. ca war voor In this do-while flowchart, the code will respond in the following steps: 1, First of all, it will execute a set of statements that is mentioned in your ‘do’ block. 2. After that, it will come to ‘while’ part where it checks the condition. 3. If the condition is true, it will go back and execute the statements. 4. If the condition is false, it will directly exit the loop. CONDITIONAL/SELECTION STATEMENTS if else-if else switch if-else Flow Chart START Condition If code executes Else code executes if First of all, it will enter the loop where it checks the condition. If the condition is true, the set of statements in ‘if’ part will be executed. if-else First of all, it will enter the loop where it checks the condition. If the condition is true, the set of statements in ‘if’ part will be executed. If the condition is false, the set of statements in the ‘else’ part will be executed. else-if FlowChart Statement 1 No statement 2 No Condition 3 Statement 3 Else body First of all, it will enter the loop where it checks the condition. If the condition is true, the set of statements in ‘if’ part will be executed. If the condition is false, it checks the set of statements in the ‘else-if’ part. If itis true it will be executed If the condition is false, the set of statements in the ‘else’ part will be executed. Note: = > Assigning Operator > Condition/Checking Operator + For primitive we must use == operator. * Fornon-primitive datatype we can use or equals operator. CONTROL STATEMENTS JUMP STATEMENTS: * break * continue BREAK: © [twill exit from the loop. © Whenever a break statement is used, the loop is terminated and the program control is resumed to the next statement following the loop FLOWCHART: Check Loop Condition EXITLOOP. Check Break ‘Statement EXIT LOOP Execute Block In this flowchart, the code will respond in the following steps: 1, First of all, it will enter the loop where it checks the condition. 2. If the loop condition is false, it directly exits the loop. 3. If the condition is true, it will then check the break condition. 4. If break condition is true, it exists from the loop. 5. If the break condition is false, then it will execute the statements that are remaining in the loop and then repeat the same steps. CONTINUE: © Itwill skip the particular iteration. * Continue statement is another type of control statements. The continue keyword causes the loop to immediately jump to the next iteration of the loop. FLOWCHART: Condition — In this flowchart, the code will respond in the following steps: 1. First of all, it will enter the loop where it checks the condition. If the loop condition is false, it directly exits the loop. 2. If the loop condition is true, it will execute block 1 statements. 3. After that it will check for ‘continue’ statement. If it is present, then the statements will not be executed in the same iteration of the loop. 4, If ‘continue’ statement is not present, then all the statements will be executed. NOTE: « Inside if we cannot create break or continue, + But inside loop if we have if/else/else-if, at that time we can give break and continue. SWITCH CASE: © Itis like if and else section statements. © Here key represents variable name. * Here value represents variable value. * After every case we must give break. SYNTAX: switch (key) { case value: break; default: break; FLOWCHART: In this Switch case flowchart, the code will respond in the following steps: 1, First of all it will enter the switch case which has an expression. 2, Next it will go to Case 1 condition, checks the value passed to the condition. If it is true, Statement block will execute. After that, it will break from that switch case. 3. In case it is false, then it will switch to the next case. If Case 2 condition is true, it will execute the statement and break from that case, else it will again jump to the next case. 4, Now let's say you have not specified any case or there is some wrong input from the user, then it will go to the default case where it will print your default statement. ARRAY ARRAY: © Storing a group of values in a single reference name, © Itallows.a same set of datatypes TYPE: © Single Dimensional Array > [] © Double or Multi Dimensional Array > [] [] SINGLE DIMENSIONAL ARRAY: © How Declare array © Insert values into array © Find the size of array © How to read/access values from array DECLARATION OF SINGLE DIMENSIONAL ARRAY: Datatype refName[ ] = new Datatypeflength] © Here, length starts from 1 ton © Then, Index starts from 0 to length -1 “a [4 ;— | INSERTION OF VALUES INTO ARRAY: OR VALUE DECLARATION: refNamefindex] = value; FIND THE SIZE OF ARRAY: refName.length; HOW TO READ OR ACCESS VALUE FROM ARRAY: + System.out.printin(); * for loop © for each loop or enhanced for loop FEATURES OF ARRAY: © Itisindex based © Itis fixed length © If we not initialize the value the default value of given datatype will be printed for that index « Ifwe assign the value for same index it will take the overrided value © Ithas high memory wastage. DIFF BETWEEN FOR AND FOR EACH LOOP: for loop * Index Based * Condition Based * Iteration is must otherwise infinite loop will be executed for each loop * Value based * No need to give any condition + No need to give any iteration IvM Stack Memory Static Memory. Follow LIFO Order. LIFO > Last In First Out. Variables and Array are stored in Stack Memory. JVM will throw StackOverFlowError Heap Memory Dynamic Memory String, StringBuffer, StringBuilder and Object. String is stored inside heap memory in a location called StringConstantPool. JVM will throw OutofMemoryError. STRING: Itisa Class. Itis index based Collection of characters enclosed within double quotes “”. String are stored in StringConstantPool (Inside Heap Memory). String is present in java.lang package. String implements from Serializable, Comparable and CharSequence interface Default value of String is null. DECLARATION OF STRING: * Byusing new keyword String refName = new String(“Data”); But we don’t declare string using above method * By using literal String refNam “data”; We declare String using literal method. String Functions; length) Iwill return length of String. Index = refName.lengt int equals|) twill check two Strings boolean equalsignoreCase() Teil check two Strings but ignore case sensitivity boolean toUpperCase() Itwill convert entire String to Capital Letters string tolowerCase() It will convert entire String to Small Letters String If we pass the index it wil return particular character. If we pass negative value hare) crunknown index twill row tingindevOutfBounds Exception at Runtime |" inecfehary EBs the character wil tun he index witch he index offist | occuring character. If we pass unknown character it will return -1. lastindexof(char) If we pass the character it will return the index. It will pe ‘the index of last int occuring character we pass unknown character will return <1 ‘ontains{character) ill check the character s present in our String boolean startsWith(String) it will check the given prefix string is present or not boolean endsWith String twill check the given suffix strings present or not boolean trim) Itwil remove unwanted space fom String string replace(old char, new char) Replace the String String concat(string) Itwill merge or adel two data string substringln index) Iti fetch the data from this given index string subString(int begin, int end-1) [twill fetch the data from this given begin index to end-1 String join) Iti add dimeters into elements string isemty() itil chek the Strings empty o not Length) ->0-> Empty boolean STRING - Part 2 function fan rte spl It will split the strings after space String[] split("") It will split each and every character including space |String[] replaceAlll() Used to replace special characters from a String String s.index(int ch, int fromIndex) |Used to find the index of middle character int STRING TYPES « Mutable or Non - Literal. « Im-Mutable or Literal. Mutable or Non - Literal String: © String Buffer and String Builder © It is stored inside heap memory. © Syntax © StringBuffer refName = new StringBuffer(“ABC") © StringBuilder refName = new StringBuilder(“AB © When we duplicate a value it will create a new memory. When we append a value the memory will be shared. o refName = refName.append(refName2); STRING BUFFER: © Itis Mutable and it is Synchronized ( Waits ) * One by One process . It is thread safe . But it is slow process. STRING BUILDER: © Itis Mutable and it is synchronized. © Itis not thread safe. But it is a fast process. Im-M. r Literal © It is stored in String Constant Pool inside heap memory. © Syntax o String refName = ““; © When we duplicate the value it will share the memory. * When we concatinate the value it will create the new memory. o refName = refName+refName2; To Find Out Memory: System.identityHashCode(refName); Thread: © Thread allows a program to operate more efficiently by doing multiple things at same time. CONSTRUCTOR * Constructor is a special type of method. * Constructor used for initializing the class variables. © Constructor name should be same as class name. © Constructor will not return any value. (not even void) * Constructor will be invoked at the time of object creation. © We can invoke only one constructor at a time using single object. TYPES: « Non-Paramaterized Constructor or Default Constructor. « Paramaterized Constructor. Method V/s Constructor ‘Method name can be anything. Method can return a value. Need to call method explicitly Constructor name must be same as class name. Constructor doesn't return a value. Automatically invoked at the time of object creation WRAPPER CLASS «© Wrapper Class convert primitive data types to objects. .P a aad Primitive Type Wrapper class boolean Boolean char Character byte Byte short Short int Integer long Long float Float double Double Converting Primitive datatypes to objects. datatype refName = value; WrapperClass objName = new WrapperClass(refName); Retrieving Primitive datatypes from objects. datatype refName = objectName; Collection : A group of objects is called Collection . It doesnt have any fixed length and no memory wastage It will allow HetroGeneous Objects ( allows different datatypes ) Collection is a Interface from java.util package Collection -> Interface Collections ---> Class Parent Class Of All Class in Java : Object Parent Interface Of All Interface in Java : Iterable Parent Class of All Exception is Throwable Parent Interface of All Interface In Selenium : Search Context Collection or Collection Wrapper Class it will wrap the Primitive Datatypes and Convert into Class object Datatype Wrapper Class Parent Class byte Byte Object short Short Object int Integer Object long Long Object float Float object double Double Object char Character object boolean Boolean object string string Object ° > generics purpose : it will protect the given datatype in inside generics ‘Type safety generics allows only Wrapper Class eg if we give Integer it will allow only Integer values if we give Boolean it will allow only true or false but if we give Object it will allow Heterogeneous Objects ‘Types List set Queque Map > Separated Interface List ( Interface It is a Interface. It is Index Based. It Allows Duplicate Values It Allows more than one null values We Cannot Create a Object For List but with help of implemented Classes like ArrayList , Linkedbist and Vector and help of upCasting we can achieve It Prints In Insertion Order For Iteration Purpose we use for , foreach , Iterator and ListIterator Object Declaration List refName = new ArrayList() ArrayList It is a Class It allow duplicate values it allow more than one null values it Prints in Insertion Order ArrayList is Asynchronzied it Supports multi threading .. Fast Process .-Thread is unsafe. Searching And Retrieving is Easy because ArrayList implements RandomAccess Insertion and Deletion is difficult Arraylist is also known as re-sizable array or dynamic Array Default Load Capacity : 10 ArrayList implements RanddomAccess, Serilazable , Cloneable It allows HeteroGenous Objects if we give Object in Wrapper class Linked List it is a class it allow duplicate values it allow more than one null values it prints in Insertion order it is Asynchronized. it supports multi-threading so thread is unsafe but fast process Insertion and Deletion is very easy because implements Queque Deque Interface and AbstractSequentialList Class Searching and retrieving is difficult it allows heterogenous objects if we give object in Wrapper class Linked List mostly stored data in the form of Doubly linked list Linked List Implements Serializable , Cloneable , Queque and Deque Interface extends from AbstractSequentialList and AbstractList previous data next Vector/ Stack it is a legacy class Since Java 1.1 or Java 1 It is Synchronized one it doesnt support multi-threading and thread will be safe and slow process List Methods method purpose Return Type add (object) add the values in insertion order - add (index, Object) add the values in particular index add (index, Object add (index, object size() it will return the count int if we give size()-1 ---> index indexOf (element) it will fetch the element index int check first occurence lastIndexOf (element ) it will fetch the last occurence int element index if we give unknown element in indeOf and lastIndexof it will throw -1 contains (element) it will check element is present in list or not boolean get(known index ) it will return the value in that particular index declared in wrapper class ) get (unknownIndex ) it will throw IndexOutOfBoundsException At Run- Time set (index, element) it will replace the value for the specified position — isEmpty () it will check the elements is present in list or not boolean addall (list) it will add the two list and stored in single list remove (index) it will remove the particular index clear () it will clear all the elements present in list and it will return as emptylist [] removeAll (list) it will compare two list and remove the common values retainall (list) it will compare two list and retain the common values. toarray () it will convert a list into Array object [ tostring() it will convert a list into String string set it is a interface it is a value based . it does not allow duplicate values. We cannot create a object for Set but with help of implemented class like HashSet , Linkeddashset and TreeSet and Upcasting here we cannot use get(), indexOf() and lastIndexof() methods because set is value based Iterate by foreach and iterator Hashset it is a class iv prints in random order it does not allow duplicate values and duplicate null values it will allow heterogenous object hashset is Asynchronized Underlying data Structure : based on Hashcode and HashMap LinkedHashset it is a class it prints in Insertion order it does not allow duplicate values and duplicate null values it will allow Heterogeneous Object it is Asynchronized . Underlying Data Structure : based on HashTable Treeset it is a class it prints in Ascending Order because it implements From SortedSet. it doesnt allow duplicate values and it doesnt allow even a single null value it is asynchronized if we add null value in Treeset ---> it will throw NullPointerException At Run-Time TreeSet does not allow Heterogeneous Objects .only allow homogeneous Objects. if we add heterogeneous objects in TreeSet --> it will throw ClassCastException at Run-Time underlying data structure : TreeSet implements From Navigableset and SortedSet and TreeMap TreeSet having a natural sorting order because of Sortedset and Comparable Interface. Map it is a interface it will separate from java.util.collection but Map is present in java.util Map is a key and Value Pair Key + value = One entry key it will allow duplicate values but fetch the override Key value : it will allow duplicate values with help of entrySet() we will iterate Map. We cant create a object for Map but with help of Implemented Classes like HashMap , LinkedHashMap , TreeMap and HashTable with help of UpCasting we can create instance. empty String = ""; emptyList = [] emptySet = [] emptyMap = {) Map Methods methods Function return Type put (Key, Value} we will insert the key and values in Map size() it will return the number of entries int size()-1 ---> index containsKey (Key ) it will check the given key is present boolean in Map or not containsValue (Value) it will check the given value is present boolean in Map or not isEmpty () it will check the map is entry or not boolean clear () it will remove all the entries in map and it will throw {} emptyMap get (Key) if we pass the key it will return value delcared in WrapperClass value if we pass unknown key it will return as null keySet () it will return all the keys present in our Map Set values () it will return all the values present in Our Map Collection entryset () it will return all the entries Set> HashMap it is a class it prints in random order Key values > allow duplicate but override values and override null Value --> allow duplicate and allow null values Asynchronized LinkedHashMap it is a class it prints in insertion order Key values > allow duplicate but override values and override null Value --> allow duplicate and allow null values synchronized TreeMap : it is a class it prints in Ascending order because its implements from NavigableMap , SortedMap Key ---> allow duplicate but override values it doesnt allow even single null values Value --> allow duplicate and allow null values Asynchronized Hashtable it is a class it prints in random order Key ---> allow duplicate but override values and doesnt allow even single null values Value --> allow duplicate but override values and doesnt allow even single null values Synchronized Inside Hashtable Class we have a Properties Class ConcurentHashmap it is a class is present in java.util.concurent it prints in random order Key : allow duplicate but only override values but doesnt allow even a single null value value allow duplicate but only override values but doesnt allow even a single null value. Asynchronized Exception Error Compile Time Memory Error FileNotFound ClassNotFound Interuppted IO Exception AWT Exception ANT --=---> Abstract Window Toolkit eg: object, Throwable Run Time Assertion Error Classcast Nul1Pointer ArrayIndexoutofBounds StringIndexoutofBounds IndexoutofBounds Arithmetic InputMissmatch TlegalArugement NumberFormate public class FileNotFound extends Exception public class ArrayIndexOutOfBounds extends Exception public class ArrayList implements List Compile Time or Checked Exception with the help of throws keywords we can easily handle Checked or Compile- Time Run-Time or Unchecked Exception with help of try ~ cateh try-multiplecatch try-finally try-catach-finally this block we easilyhandle Run-Time or Unchecked Exception try: it is a block At will try to execute the code in inside the try block if it throw Exception > it will go to catch Block if there is no exception- => it will not go to the catch block cateh: it is a block it will catch the exception which is occured in the try block catch block must be parameterized . parameterinozed belongs to ChildClass Exception or Exception if we can give multiple catch block / overload the catch block but order should be child and parent In inside catch block if any exception occurs if it will not handled by catch block then it will throw the exception at run-time and terminate the program finally : it is a block wheather exception occured or not in try block, execution will takes place inside finally block. by using System.exit (0) it will terminate the entire program / currently running java virtual Machine Exception: Program will terminate at the line itself it will throw the Exception with help of > trace the exception and print in console printStackTrace() > it involves with printStackTrace() ~: ErrorOutputstream. throw throws it is a keyword at is a keyword location inside the method in the method level purpose throw the Exception Declare the exception it will throw only one exception at will declare more than one exception at a time at a time public public public public class FileNotFoundException extends Exception class IOException extends Exception class Interupptedzxception extends Exception class ArrayList implements List SELENIUM TESTING COURSE CONTENT PRE-SELENIUM Core Java Programming Introduction to Java istory of java Comparison with C and C+ Features of Java JDK JRE,VM overview JDK Directory Structure Basic Java Program through command prompt Installation and Setup: Packages Download and install JDK/JRE Set Environment variables Download Eclipse IDE Coding standards followed in E Naming standards followed in Eclipse Features of Eclipse IDE se Introduction to packages Need for packages package declaration in Java Import statement in Java static import in java Resolving name clashes in packages OOPS and its application in Java: Classes and Objects Defining a class, instance variable and method in Java Defining a class, variable and method in Java Creating objects out of a class Method calls via object references Abstraction Interfaces and Abstract classes Abstract and non-abstract methods Edit with WPS Office & Java Sy Maver gp cucumber = J TestNG git Jenkins Inheritance + extends and implements keywords in Java + Typesof inheritance * Super class and Sub class. * thiskeyword, super keyword in Java for inheritance * Concrete classes in Java Aggregation and Association Polymorphism: Compile time polymorphism -Overloading of methods Run time polymorphism -Overriding of methods Method Overriding rules and method overloading rules Introduction to Object class and it's methods Encapsulation: Protection of data Java Bean, POJO Getters/Setters Memory management in Java Heap Stack Garbage Collection Data types Primitive Data types Data type Declarations Data type Rangesand its calculation Memory allocation for each Data type Variable Names Conventions Numeric Literals, Character Literals String Literals Arrays Array of Object References Enumerated Data types Non-Primitive Data types Operators: Expressions in Java Assignment Operator Arithmetic Operators 2 Edit with WPS Office + Relational Operators * Logical Operators * Conditional Operators * Operator Precedence + Implicit Type Conversions + Upcasting and downcasting * Strict typing + Type conversion Conditional Control Statements * Flowchart for conditional statements + Ifstatement + Ifelse statement * Ifelse-if statement * Switch statement * String in switch case Looping Control Statements + For loop = While loop + Do-while loop + Unconditional Control Statements + break statement + labelled break statement + return statement + continue statement Scanner class: + Scanner and BufferedReader + Methods to get Primitive data types + match method .d r method + findinLine method + skip,close method + useRadix method * useLocale method + IOException method 2 Edit with WPS Office De-buggin + Launching and debugging java code + Breakpoints + Debug perspective * Stepping commands + Trace point, Trigger point + Breakpoints grouping + Breakpoints sorting ‘Access Modifers in Java + Role of access modifiers + Private access modifier Role of private constructor Default access modifier Protected access modifier Public access modifier ‘Access Modifier with Method Overriding Types of variable: * variable variable memory storage Static variable Local variable Global/nstance Variable variable widening variable narrowing Constructor: + Constructor + Default constructor + Non-arg based constructor + Parameterised constructor * Difference between Constructor and Method * Constructor chaining + this and super method + constructor overloading Singleton class: * Singleton class + Normal class vs singleton class 2 Edit with WPS Office * Use of Singleton class * JDBC Using Model Object and Singleton Class + Collections.singleton method in Java * Private Constructors and Singleton Classes in Java * Java Singleton Design Pattern Practices Factory Design Pattern: + Factory Design Pattern: + Advantage of Factory Design Pattern «Implementing Factory Design Pattern + Abstract Factory Design Pattern * Overview of other creational design pattern * Builder design pattern + String data type * String declaration * String Tokenizer + String methods + String types + String memory allocation + Manipulations in string + Interfaces and classes in String Arrays: + Declaration + Instantiation + Initialization of Java Array + Single dimensional Array + Multidimensional Array * Anonymous Array * Cloning an Array Wrapper class: + Need of Wrapper classes + Autoboxing and Unboxing © Primitive Wrapper Classes * Utility methods of Wrapper classes + valueOf and xxxValue methods * parseXxx and toString methods 2 Edit with WPS Office + Need for Generics + How Generics works in Java + Types of Generics + Generic Type Class or Interface + Generic Type Method or Constructor + Generic Type Arrays, + Generics with Wildcards + Unbounded Wildcards + Bounded Wildcards Collection: * Java Collection Framework * Hierarchy of Collection Framework * Collection interface + Iterator interface + Methods of collection interface + List + Set * Queue * Collections utility class + Introduction to Map interface + Methods in Map © Iterating a Map + Map hierarchy * Sorted Map + LinkedHashMap * TreeMap * HashMap * HashTable Exception handling: * Exception types © Usage of Try * Usage of Catch * Usage of Throw * Usage of Throws 2 Edit with WPS Office + Usage of Finally * Built-in Exceptions, + Creating own Exception classes Java Regex: + Regular expression + MatchResult interface + Matcher class + Pattern class * PatternSyntaxException class © Regex Quantifiers + Regular Expression Character classes + Regex Metacharacters File operations: + File Handling in Java + Stream * Java File Methods + File Operationsin Java + File reader + File writer * Buffered Reader + File permissions Date and Time: + Method & Description + Date Comparison’ + Date Formatting Using SimpleDateFormat + SimpleDateFormat Codes + Date Formatting Using printf + Date and Time Conversion Characters + Sleeping for a While + GregorianCalendar Class ization: + Serialization in Java + Need for Serialization in Java + Serializing an Object 2 Edit with WPS Office + Deserializing an object * Advantages and Disadvantages of Serialization in Java + Practical examples of Serialization in Java + Externalizable Interface * Transient Keyword * Serial Version UID * Controversies of Serialization in Java * Best Practices while using Serialization in Java * Introduction to XML + Read XML File in Java + Java DOM Parser + Java SAX Parser + Read XML File in Java Using eclipse + Reading XML file using DOM Parser + Reading XML file using SAX parser + JSONArray + JSONParser + JSONObject » Json.simple maven dependency + Write JSON to file with json-simple + Read JSON from file with json-simple + Download Sourcecode + Read CSV File in Java + CSV file creation + How to create CSV File + Java Scanner class + Java String split() method + Using Opencsv API + Reading CSV file with a different separator Multi-threading: * Concepts of Thread + Thread life cycle * Creating threads using Thread class and Runnable interface 2 Edit with WPS Office * Synchronization * Thread priorities * Inter Thread communication. idk 15 features: + Autoboxing * Generics + Enhanced for loop + Varargs © Enums + Static imports © C-lang printf() + StringBuilder + Metadata idk 17 features: + String in Switch Expression. + Underscores Between Digits in Numeric Literals. + Integral Types as Binary Literals. + Handling multiple exceptions in a single catch block + Try-with-resources Statement. + Automatic Type Inference in Generic object instantiation idk 18 features: + Lambda Expression + Method references + Functional interfaces + Interface changes: Default and static methods + Streams + Stream filter + forEach) * Collectors class with example + StringJoiner class with example * Optional class with example + Arrays Parallel Sort Memory management: + JVM Memory Structure + Heap area + Method Area 2 Edit with WPS Office JVM Stacks Native method Stacks Program counter (PC) registers Working of Garbage Collector Memory leaks in Java Introduction to SQL Table creation SQL Insert SQL Update Applying Constraints SQL Syntax SQL Data Types SQL Operators SQL Database SQL Select SQL Clause SQL Delete SQL Join SQL Keys JDBC Connection: Establishing connection Types of JDBC driver JDBC-ODBC Bridge Driver, Native Driver, Network Protocol Driver, and Thin Driver Running query Extracting Result Java programs: Check the given number is odd or not Check the given number is even or not Print first 100 odd numbers Print first 100 even numbers Count the number of even numbers from 1to 100 Count the number of odd numbers from 1to 100 Find the factorial of a given number 2 Edit with WPS Office Generating fibbonacci series Find the reverse of the given number Check the given number is palindrome or not Check the given number is armstrong or not Find the sum of the digits in a number Find the number of digits in @ number Find the product of digits in a number Find the reverse of the string Check the given string is palindrome or not Print each word's first letter of the given string in capital number Print the duplicate numbers in array Print the Unique elements in array Remove the duplicate character in string Remove the duplicate words in string Write code to print patterns Pre-increment post increment example prime number or not Anagram or not Usage of Collections min(,max() and sort) Usage of Arrays.min(),max() and sort) Print numbers as String Coding standards: Coding Standards for Classes Coding Standards for Interface Coding Standards for Methods Coding Standards for Variables Coding Standards for Constants Java Bean Coding Standards Getter Methods Setter Methods 2 Edit with WPS Office SELENIUM: Selenium Introduction Types of Applications (Desktop, Web, Mobile, Hybrid) Software Testing Methods (Manual and Test Automation). Selenium Introduction Selenium Components Selenium vs. Other Testing Tools Advantages of Selenium Integration of Selenium with Other Tools Selenium Components: Purposes and functionalities Understanding the components Selenium RC Selenium IDE Selenium webdriver Selenium Grid When to use Grid WebDriver Third party drivers and plugins Driver requirements What is WebDriver Selenium Architechture Simple Program in Selenium WebDriver WebDriver methods Types Of Browser Launch Desired Capability Downloading driver file Downloading selenium jarfile Chrome Browser Launching Safari Browser Launching InternetExplorer Browser Launching Installing FireBug and FirePath Firefox Browser Launching 2 Edit with WPS Office Locators Xpath id name classname xpath tagName linkText partialLinkText cssSelector Contains xpath Text Xpath Text Contains Xpath Attribute with contains Following Ancestor Child Preceding Following-sibling Parent Self Descendant Types Of Xpath Relative Xpath Absolute Xpath Difference between Absolute Xpath and Relative Xpath Limitations in Absolute xpath Advantages of using Relative xpath Check Box Finding checkboxes count Checking the visiblity of Check Box Checking the properties of Check Box Identifying common locator for all checkboxes Checking toggled attribute 2 Edit with WPS Office Text Box Handling the Text Box Checking the visiblity of Text Box Checking the properties of Text Box Identifying common loactor for all TextBoxes Finding Textboxes count Radio Button Handling the Radio Button Checking the visiblity of Radio Button Checking the properties of Radio Button Identifying common loactor for all Radiobuttons Finding radiobuttons count WebElement What are WebElements in Selenium Different types of WebElements Operations performed on the WebElements How to locate the WebElements on the web page Different WebElement methods Difficulties while handling webElemens. Dynamic Locators Absolute XPath method Relative XPath method Identify by index Preceeding-sibling,Following-sibling concept Ancestor parent concept Common tagname(*) method Multiple attributes to locate an element Desired Capability Need for Desired Capabilities Different types of Desired Capabilities Methods Example for set capability method Setting the Property Getting the Property 2 Edit with WPS Office Navigation Commands + Navigate To Command * Forward Command + Back Command + Refresh Command * navigate method over get method + Navigation by using JavascriptExecutor WebDriver Commands * Fetching a web page ‘* Locating elements and sending user inputs * Clearing User inputs + Fetching data over any web element + Performing Click event + Navigating backward in browser history + Navigating forward in browser history + Refresh/Reload a web page * Closing Windows * Closing Browser + Handling Windows * Handling Frames + Handling Drag and Drop Actions + Drag and Drop + Mouseover Action Right Click * Double Click + Performing Multiple Actions + Accessing modifier keys using Actions class + Switching into Alert + Alert methods + Typesof Alert + Handling the Alert + Passing the inputs to Alerts 2 Edit with WPS Office * Entering text into Alert * Get the text present in Alert Pop-ups + Handling the Window based popups + Handling the Notification popups + HAndling pop-upsusing Robot class + Handling the Login popups * Chrome Options + FirefoxOptions + InternetExplorerOptions Robot Class * Need of Robot Class + Methods to implement this class + Mouse click using Robot class * Limitations + Copy Operations + Cut Operations + Paste Operations © File Uploading © Alert Handling + Need for Waits + Static waits + Dynamic waits + Implicit Waits + Explicit Waits + Fluent Waits » WebDriver Waits JavaScript + WebElement Highlighting + Click Operation * Fetching the Data from Weblement + Sending the Inputs to WebElement * Scrolling Operations * Highlighting a WebElement 2 Edit with WPS Office ScrollUp/ScrollDown Scroll the web page by pixel Scroll the web page by the visibility of the element Scroll down the web page at the bottom of the page Horizontal scroll on the web page Multiple Scroll ScrollBy coordinates Frames Need for Frames Identifying a Frame ‘Switching to Frames using Selenium WebDriver Different ways of switching Dynamic frames handling Frames Size Concept of Nested Frames Windows Handling Importance of Windows Handling Handling the Multiple Windows Windows Handling using Set Windows Handling using List WebTable Analyzing WebTable structure in DOM Handling multiple webtables in a page Dynamically changing WebTable handling Extracting values from webTable Analyzing the Tagnames Different Scenarios with WebTable Dynamic WebTable Handling Dynamic Tables In Selenium Analyzing the Dynamic WebTable Analyzing the HTML Tags in Dynamic WebTable Different Scenario with Dynamic WebTable 2 Edit with WPS Office ScreenShot Need of Screenshot in Automation testing Capture Screenshot in Selenium Capture Full Page Screenshot Taking a Screenshot of a particular element of the page Taking a Screenshot with different file formats Random name generation for screenshots Finding images count in webpage Finding broken images count in webpage Finding broken image URL JavaSoriptExecutor code to verify if image code to print desired output as per image Identifying URL Validating URL To Find a broken links HTTP response code Collect all the links in the web page DropDown Select class in Selenium WebDriver Different Select commands Multiple Select commands Deselect Commands Get All options Dropdown without Select tag Handling dropdown with values changing its position dynamically. File Upload/File Download Uploading files in Selenium WebDriver using Sendkeys Uploading files in Selenium WebDriver using Robot Class Uploading files in Selenium WebDriver using Auto!T Download files in Selenium WebDriver using Sendkeys Download files in Selenium WebDriver using Robot Class 2 Edit with WPS Office * Download files in Selenium WebDriver using AutolT Auto IT + download and install AutolT * Finding element through element Identifier © Writing script on AutolT editor + AutolT Upload file in Selenium Webdriver Tooltip: + Advanced User Interactions API ‘+ Get Tooltip Text in Selenium Webdriver + Tooltip using the "title" attribute + Tooltip using a jQuery plugin Browser Stack * Introduction to Browser Stack + Cross Browser Testing + BrowserStack History + Features of BrowserStack + Testing The Web Application + Browser Stack Key Functions * Testing The Mobile Application In Mobile Browsers + Testing Of Native,Hybrid Mobile Application In BrowserStack Sauce Lab + Saucelab-Introduction * Value Proposition + Manual testing on Sauce labs + Post Execution * Automated Test Execution + saucelabs gem » Execution and Results Maven * Introduction to Apache Maven * Maven Dependencies * Maven Plugins * Controlling The Build Edit with WPS Office

You might also like