├── .gitignore └── src ├── AcceM1 ├── Contractor.java ├── Emp.java └── QA.java ├── AcceM2 ├── HR.java └── Vendor.java ├── ConstructorConcept ├── Employee.java ├── Person.java ├── Product.java └── ProductTest.java ├── ExceptionHandling ├── ThrowKeyword.java ├── ThrowsKeyword.java ├── TryCatchBlock.java └── TryCatchPart2.java ├── JavaSessions ├── A.java ├── ArrayListConcept.java ├── ArraysConcept.java ├── B.java ├── Car.java ├── CarDesign.java ├── ConditionalOperatorsIFElse.java ├── DataConversion.java ├── DataTypes.java ├── Ecomm.java ├── EmpTest.java ├── Employee.java ├── FinalizeMethodConcept.java ├── FinallyConcept.java ├── FunctionsInJava.java ├── HashMapConcept.java ├── IncrementalAndDecrementalOperators.java ├── Login.java ├── LoopsConcept.java ├── MainMethodOverloading.java ├── MethodOverloading.java ├── Person.java ├── StringConcatenation.java ├── StringManipulation.java └── TimeCompexity.java ├── OOP_Abstract ├── Cloud.java ├── LoginPage.java ├── Page.java └── TestPage.java ├── OOP_Encapsulation ├── AmazonTest.java ├── Browser.java ├── BrowserUser.java ├── Company.java ├── EmpTest.java ├── Employee.java └── LoginPage.java ├── OOP_Inheritance ├── Audi.java ├── BMW.java ├── Car.java ├── CarTest.java ├── Truck.java └── Vehicle.java ├── OOP_Interface ├── CentralizedHospital.java ├── FHTrust.java ├── FortisHospital.java ├── IndianMedical.java ├── TestHospital.java ├── UKMedical.java ├── UN.java ├── UNHG.java ├── USMedical.java └── WHO.java ├── OOP_Interface_WebDriverExample ├── AmazonTest.java ├── ChromeDriver.java ├── FirefoxDriver.java ├── SafariDriver.java ├── SearchContext.java └── WebDriver.java └── ThisKeyword ├── EComm.java └── Shopping.java /.gitignore: -------------------------------------------------------------------------------- 1 | allure-results/ 2 | screenshots/ 3 | test-output/ 4 | 5 | 6 | ############################## 7 | ## Java 8 | ############################## 9 | .mtj.tmp/ 10 | *.class 11 | *.jar 12 | *.war 13 | *.ear 14 | *.nar 15 | hs_err_pid* 16 | ############################## 17 | ## Maven 18 | ############################## 19 | target/ 20 | pom.xml.tag 21 | pom.xml.releaseBackup 22 | pom.xml.versionsBackup 23 | pom.xml.next 24 | pom.xml.bak 25 | release.properties 26 | dependency-reduced-pom.xml 27 | buildNumber.properties 28 | .mvn/timing.properties 29 | .mvn/wrapper/maven-wrapper.jar 30 | 31 | ############################## 32 | ## IntelliJ 33 | ############################## 34 | out/ 35 | .idea/ 36 | .idea_modules/ 37 | *.iml 38 | *.ipr 39 | *.iws 40 | ############################## 41 | ## Eclipse 42 | ############################## 43 | .settings/ 44 | bin/ 45 | tmp/ 46 | .metadata 47 | .classpath 48 | .project 49 | *.tmp 50 | *.bak 51 | *.swp 52 | *~.nib 53 | local.properties 54 | .loadpath 55 | .factorypath 56 | 57 | ## OS X 58 | ############################## 59 | .DS_Store -------------------------------------------------------------------------------- /src/AcceM1/Contractor.java: -------------------------------------------------------------------------------- 1 | package AcceM1; 2 | 3 | public class Contractor { 4 | 5 | public static void main(String[] args) { 6 | 7 | 8 | Contractor c = new Contractor(); 9 | 10 | Emp e = new Emp(); 11 | 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /src/AcceM1/Emp.java: -------------------------------------------------------------------------------- 1 | package AcceM1; 2 | 3 | public class Emp { 4 | 5 | public String name = "Tom"; 6 | private int age = 25; 7 | protected double salary = 34.55; 8 | char c = 'm'; 9 | 10 | public static void main(String[] args) { 11 | 12 | Emp e = new Emp(); 13 | System.out.println(e.name); 14 | 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /src/AcceM1/QA.java: -------------------------------------------------------------------------------- 1 | package AcceM1; 2 | 3 | import java.util.Arrays; 4 | 5 | public class QA extends Emp{ 6 | 7 | public static void main(String[] args) { 8 | 9 | QA qa = new QA(); 10 | System.out.println(qa.salary); 11 | 12 | 13 | 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /src/AcceM2/HR.java: -------------------------------------------------------------------------------- 1 | package AcceM2; 2 | 3 | import AcceM1.Emp; 4 | 5 | public class HR extends Emp{ 6 | 7 | public static void main(String[] args) { 8 | 9 | HR hr = new HR(); 10 | Emp e = new Emp(); 11 | 12 | System.out.println(e.name); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /src/AcceM2/Vendor.java: -------------------------------------------------------------------------------- 1 | package AcceM2; 2 | 3 | import AcceM1.Emp; 4 | 5 | public class Vendor { 6 | 7 | public static void main(String[] args) { 8 | 9 | Emp e = new Emp(); 10 | System.out.println(e.name); 11 | 12 | 13 | 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /src/ConstructorConcept/Employee.java: -------------------------------------------------------------------------------- 1 | package ConstructorConcept; 2 | 3 | public class Employee { 4 | 5 | //class vars: 6 | String name; 7 | int age; 8 | int empId; 9 | double salary; 10 | boolean isPermanent; 11 | char gender; 12 | 13 | //constructor of the class: 14 | //looks like a function, but its not a function 15 | //const... name will be as same as the class name 16 | //a function may or may not return a value but const.. will never return a value 17 | //no return and void keywords in cost.... 18 | //can overload the const... 19 | //const.. will be called when we create the object of the class. 20 | 21 | 22 | public Employee(){ //0 param //default const.. 23 | System.out.println("default emp const..."); 24 | System.out.println("Hello Employee!!!"); 25 | } 26 | 27 | public Employee(int i){ 28 | System.out.println("1 param const.." + i); 29 | } 30 | 31 | public Employee(int i, String p){ 32 | System.out.println("2 params const.." + i + p); 33 | } 34 | 35 | 36 | public static void main(String ar[]){ 37 | System.out.println("hello"); 38 | //const.. will be called when we create the object of the class. 39 | Employee e1 = new Employee(); 40 | Employee e2 = new Employee(10); 41 | Employee e3 = new Employee(20, "testing"); 42 | 43 | 44 | } 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | } 54 | -------------------------------------------------------------------------------- /src/ConstructorConcept/Person.java: -------------------------------------------------------------------------------- 1 | package ConstructorConcept; 2 | 3 | public class Person { 4 | 5 | //class vars 6 | String name; 7 | int age; 8 | double salary; 9 | boolean isPermanent; 10 | char gender; 11 | 12 | public Person(){ 13 | System.out.println("Hello Person"); 14 | } 15 | 16 | public Person(String name) { 17 | this.name = name; 18 | } 19 | 20 | public Person(String name, int age){ 21 | this.name = name; 22 | this.age = age; 23 | } 24 | 25 | public Person(String name, int age, double salary){ 26 | this.name = name; 27 | this.age = age; 28 | this.salary = salary; 29 | } 30 | 31 | public Person(String name, int age, double salary, boolean isPermanent, char gender) { 32 | this.name = name; 33 | this.age = age; 34 | this.salary = salary; 35 | this.isPermanent = isPermanent; 36 | this.gender = gender; 37 | } 38 | 39 | public static void main(String[] args) { 40 | 41 | Person p1 = new Person("Nikita", 25); 42 | System.out.println(p1.name); 43 | System.out.println(p1.age); 44 | 45 | Person p2 = new Person("Supriya", 26, 45.55); 46 | System.out.println(p2.name + " " + p2.age + " " + p2.salary); 47 | 48 | Person p3 = new Person("Anu", 24, 23.44, false, 'F'); 49 | System.out.println(p3.name + " " + p3.isPermanent); 50 | System.out.println(p3.salary); 51 | 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /src/ConstructorConcept/Product.java: -------------------------------------------------------------------------------- 1 | package ConstructorConcept; 2 | 3 | import java.util.ArrayList; 4 | 5 | public class Product { 6 | String name; 7 | double price; 8 | String color; 9 | ArrayList sellerList; 10 | 11 | public Product(String name, double price) { 12 | this.name = name; 13 | this.price = price; 14 | } 15 | 16 | public Product(String name, double price, String color) { 17 | this.name = name; 18 | this.price = price; 19 | this.color = color; 20 | } 21 | 22 | public Product(String name, double price, String color, ArrayList sellerList) { 23 | this.name = name; 24 | this.price = price; 25 | this.color = color; 26 | this.sellerList = sellerList; 27 | } 28 | 29 | 30 | public void getName(){ 31 | System.out.println("get name..."); 32 | } 33 | 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/ConstructorConcept/ProductTest.java: -------------------------------------------------------------------------------- 1 | package ConstructorConcept; 2 | 3 | import java.util.ArrayList; 4 | 5 | public class ProductTest { 6 | 7 | public static void main(String[] args) { 8 | 9 | Product p1 = new Product("Nike Shoes", 5000); 10 | System.out.println(p1.name + " " + p1.price + " " + p1.color + " " + p1.sellerList); 11 | 12 | ArrayList appleSellerList = new ArrayList(); 13 | appleSellerList.add("Neon Enterprise Ltd"); 14 | appleSellerList.add("Xeon Computers"); 15 | appleSellerList.add("Ali IT software"); 16 | 17 | Product p2 = new Product("Apple MacbookPro", 2.3, "White", appleSellerList); 18 | System.out.println(p2.name + " " + p2.price + " " + p2.color + " " + p2.sellerList); 19 | System.out.println(p2.sellerList.get(0)); 20 | 21 | for (String ele : p2.sellerList) { 22 | System.out.println(ele); 23 | } 24 | 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/ExceptionHandling/ThrowKeyword.java: -------------------------------------------------------------------------------- 1 | package ExceptionHandling; 2 | 3 | public class ThrowKeyword { 4 | 5 | public static void main(String[] args) { 6 | 7 | System.out.println("Hello Testing"); 8 | 9 | // try { 10 | // throw new Exception("Some Exception is coming..."); 11 | // } catch (Exception e) { 12 | // e.getMessage(); 13 | // e.printStackTrace(); 14 | // } 15 | 16 | String s = null; 17 | 18 | if(s == null) { 19 | System.out.println("Bye"); 20 | 21 | try { 22 | throw new Exception("Excel Value Exception - value is null"); 23 | } 24 | catch(Exception e) { 25 | e.printStackTrace(); 26 | } 27 | } 28 | 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/ExceptionHandling/ThrowsKeyword.java: -------------------------------------------------------------------------------- 1 | package ExceptionHandling; 2 | 3 | public class ThrowsKeyword { 4 | 5 | public static void main(String[] args) { 6 | 7 | ThrowsKeyword obj = new ThrowsKeyword(); 8 | obj.m1(); 9 | 10 | } 11 | 12 | public void m1() { 13 | System.out.println("m1 method"); 14 | m2(); 15 | } 16 | 17 | public void m2() throws ArithmeticException{ 18 | System.out.println("m2 method"); 19 | 20 | try { 21 | m3(); 22 | } catch (ArithmeticException e) { 23 | System.out.println("AME is coming..."); 24 | } 25 | 26 | } 27 | 28 | public void m3() { 29 | System.out.println("m3 method"); 30 | 31 | try { 32 | int i = 9 / 0; 33 | } catch (ArithmeticException e) { 34 | System.out.println("AME is coming..."); 35 | } 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /src/ExceptionHandling/TryCatchBlock.java: -------------------------------------------------------------------------------- 1 | package ExceptionHandling; 2 | 3 | public class TryCatchBlock { 4 | 5 | public static void main(String[] args) { 6 | 7 | System.out.println("Hi"); 8 | System.out.println("Hi"); 9 | System.out.println("Hi"); 10 | System.out.println("Hi"); 11 | 12 | int k = 10/0; 13 | 14 | try { 15 | System.out.println("Hello"); 16 | int i = 9/3; 17 | System.out.println("testing"); 18 | System.out.println("testing"); 19 | System.out.println("testing"); 20 | 21 | } 22 | catch(ArithmeticException e) { 23 | System.out.println("some exception is coming...bye!!"); 24 | //e.printStackTrace(); 25 | //System.out.println(e.getMessage()); 26 | } 27 | 28 | System.out.println("Hi"); 29 | System.out.println("Hi"); 30 | 31 | 32 | 33 | 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/ExceptionHandling/TryCatchPart2.java: -------------------------------------------------------------------------------- 1 | package ExceptionHandling; 2 | 3 | public class TryCatchPart2 { 4 | 5 | String name = "Tom"; 6 | 7 | public static void main(String[] args) { 8 | 9 | System.out.println("Hello Testing"); 10 | 11 | TryCatchPart2 obj = new TryCatchPart2(); 12 | 13 | obj = null; 14 | 15 | try { 16 | int i = 9/3; 17 | System.out.println(obj.name); 18 | } 19 | catch (NullPointerException e) { 20 | System.out.println("NPE is coming...."); 21 | } 22 | catch(ArithmeticException e) { 23 | System.out.println("AME is coming"); 24 | e.printStackTrace(); 25 | } 26 | 27 | System.out.println("Bye!!"); 28 | 29 | 30 | 31 | 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /src/JavaSessions/A.java: -------------------------------------------------------------------------------- 1 | package JavaSessions; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Arrays; 5 | 6 | public class A { 7 | 8 | public static void main(String[] args) { 9 | 10 | System.out.println("A -- main method"); 11 | 12 | B.main(args);//StackOverflowError 13 | 14 | 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /src/JavaSessions/ArrayListConcept.java: -------------------------------------------------------------------------------- 1 | package JavaSessions; 2 | 3 | import java.util.ArrayList; 4 | 5 | public class ArrayListConcept { 6 | 7 | public static void main(String[] args) { 8 | 9 | //ArrayList is a default class in Java 10 | //dynamic array 11 | //order based/index based arraylist/collection 12 | //Li = 0 13 | //Hi = size -1 14 | //size = ar.size() 15 | 16 | ArrayList ar = new ArrayList(); 17 | System.out.println(ar.size()); 18 | 19 | ar.add(100);//0 20 | ar.add(200);//1 21 | 22 | System.out.println(ar.size()); 23 | 24 | ar.add(300);//2 25 | ar.add(400);//3 26 | 27 | System.out.println(ar.size()); 28 | 29 | ar.add(500);//4 30 | ar.add(600);//5 31 | ar.add(700);//6 32 | //ar.remove(6);//700 33 | 34 | System.out.println(ar.size());//7 35 | 36 | ar.add(800);//7 37 | System.out.println(ar.get(6)); 38 | 39 | ar.add(900);//8 40 | ar.add(1000);//9 41 | 42 | System.out.println(ar.size());//10 43 | 44 | ar.add(1100); 45 | 46 | ar.add(12.33); 47 | ar.add(true); 48 | ar.add('f'); 49 | ar.add("tom"); 50 | 51 | //to print all the values from arraylist: for loop: 52 | for(int i=0; i marksList = new ArrayList(); 59 | marksList.add(100); 60 | marksList.add(200); 61 | 62 | ArrayList countryList = new ArrayList(); 63 | countryList.add("India");//0 64 | countryList.add("UK"); 65 | countryList.add("USA"); 66 | countryList.add("Germany");//3 67 | 68 | System.out.println(countryList.size()); 69 | System.out.println(countryList.get(0)); 70 | //System.out.println(countryList.get(4)); 71 | 72 | for(int i=0; i System.out.println(ele)); 84 | 85 | 86 | //store a list with different types of data: emp data 87 | 88 | ArrayList empDataList = new ArrayList(); 89 | empDataList.add("Tom"); 90 | empDataList.add(25); 91 | empDataList.add('m'); 92 | empDataList.add(true); 93 | empDataList.add(34.55); 94 | 95 | empDataList.stream().forEach(data -> System.out.println(data)); 96 | 97 | } 98 | 99 | } 100 | -------------------------------------------------------------------------------- /src/JavaSessions/ArraysConcept.java: -------------------------------------------------------------------------------- 1 | package JavaSessions; 2 | 3 | public class ArraysConcept { 4 | 5 | public static void main(String[] args) { 6 | 7 | //two major limitations of array: 8 | //1. static arrays -- size is fixed -- to overcome this issue, we use dynamic arrays (ArrayList) 9 | //2. it stores only similar types of data -- to overcome this issue, we can use Object static Array and ArrayList 10 | 11 | //int array: 12 | int i[] = new int[4]; 13 | 14 | //i[-1] = 60; 15 | i[0]=10; 16 | i[1]=20; 17 | i[2]=30; 18 | i[3]=40; 19 | //i[4]=50; //ArrayIndexOutOfBoundsException 20 | 21 | System.out.println("li = " + 0); 22 | System.out.println(i.length); 23 | System.out.println("hi = " + (i.length-1)); 24 | 25 | System.out.println(i[0]); 26 | System.out.println(i[3]); 27 | //System.out.println(i[4]);//ArrayIndexOutOfBoundsException 28 | //System.out.println(i[-1]);//ArrayIndexOutOfBoundsException 29 | 30 | int l = i.length;//4 31 | 32 | //to print all the values from array: use for loop: 33 | for(int p=0; p b); 11 | 12 | if (a > b) { 13 | System.out.println("a is greater than b"); 14 | } else { 15 | System.out.println("b is greater than a"); 16 | } 17 | 18 | if (false) { // Dead code 19 | System.out.println("Hii"); 20 | } else { // Dead code 21 | System.out.println("Bye..."); 22 | } 23 | 24 | String s = "Hello"; 25 | String s1 = "hello"; 26 | 27 | if (s.equalsIgnoreCase(s1)) { 28 | System.out.println("both are equal"); 29 | } else { 30 | System.out.println("both are not equal"); 31 | 32 | } 33 | 34 | int total = 100; 35 | int fee = 100; 36 | 37 | if (total == fee) { 38 | System.out.println("total is fee"); 39 | } else { 40 | System.out.println("total is not fee"); 41 | } 42 | 43 | if (12 == 12.22) { 44 | System.out.println("Hello"); 45 | } 46 | 47 | // > < >= <= == != 48 | int c = 2000; 49 | int d = 2000; 50 | if (d >= c) { 51 | System.out.println("PASS"); 52 | } 53 | 54 | int balance = 101; 55 | if (balance != 100) { 56 | System.out.println("bal is not correct"); 57 | } 58 | 59 | int marks = 200; 60 | 61 | if (marks >= 90) { 62 | if (marks <= 100) { 63 | System.out.println("PASS"); 64 | 65 | } else { 66 | System.out.println("wrong marks"); 67 | } 68 | } else { 69 | System.out.println("FAIL"); 70 | } 71 | 72 | // WAP to find out the highest number where three different numbers are 73 | // given: 74 | int x = 500; 75 | int y = 600; 76 | int z = 300; 77 | // && - AND operator -- > Short Circuit Operator 78 | // || - OR --> 79 | if (x > y && x > z) {// false && true 80 | System.out.println("x is the greatest"); 81 | } else if (y > z) {// true 82 | System.out.println("y is the greatest"); 83 | } else { 84 | System.out.println("z is the greatest"); 85 | } 86 | 87 | // WAP to check the browser value and then launch the respective 88 | // browser: 89 | 90 | String browser = "chrome"; 91 | 92 | // 1. only if-else 93 | if (browser.equals("chrome")) { 94 | System.out.println("launch chrome"); 95 | } 96 | 97 | if (browser.equals("firefox")) { 98 | System.out.println("launch firefox"); 99 | } 100 | 101 | if (browser.equals("ie")) { 102 | System.out.println("launch ie"); 103 | } 104 | 105 | if (browser.equals("safari")) { 106 | System.out.println("launch safari"); 107 | } 108 | 109 | else { 110 | System.out.println("please pass the correct browser name"); 111 | } 112 | 113 | // 2. if-elseif-else 114 | if (browser.equals("chrome")) { 115 | System.out.println("launch chrome"); 116 | 117 | } else if (browser.equals("firefox")) { 118 | System.out.println("launch firefox"); 119 | } else if (browser.equals("IE")) { 120 | System.out.println("launch IE"); 121 | } else if (browser.equals("Safari")) { 122 | System.out.println("launch Safari"); 123 | } else { 124 | System.out.println("please pass the correct browser name"); 125 | } 126 | 127 | // 3. switch-case: 128 | 129 | switch (browser) { 130 | case "chrome": 131 | System.out.println("launch chrome"); 132 | break; 133 | case "firfox": 134 | System.out.println("launch firefox"); 135 | break; 136 | case "IE": 137 | System.out.println("launch IE"); 138 | break; 139 | case "safari": 140 | System.out.println("launch safari"); 141 | break; 142 | 143 | default: 144 | System.out.println("please pass the correct browser name"); 145 | break; 146 | } 147 | 148 | } 149 | 150 | } 151 | -------------------------------------------------------------------------------- /src/JavaSessions/DataConversion.java: -------------------------------------------------------------------------------- 1 | package JavaSessions; 2 | 3 | public class DataConversion { 4 | 5 | public static void main(String[] args) { 6 | 7 | 8 | //String to int: 9 | String x = "100"; 10 | 11 | System.out.println(x+20);//10020 12 | 13 | int i = Integer.parseInt(x);//100 14 | System.out.println(i+20);//120 15 | 16 | String amount = "1000"; 17 | 18 | 19 | //String to double: 20 | String y = "34.55"; 21 | System.out.println(y+20); 22 | double d = Double.parseDouble(y); //34.55 23 | System.out.println(d+20); 24 | 25 | 26 | String h = "100A"; 27 | // int p = Integer.parseInt(h);//NumberFormatException 28 | // System.out.println(p+20); 29 | 30 | //int to String: 31 | int k = 100; 32 | System.out.println(k+20); 33 | String k1 = String.valueOf(k); // "100" 34 | System.out.println(k1+20); 35 | 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /src/JavaSessions/DataTypes.java: -------------------------------------------------------------------------------- 1 | package JavaSessions; 2 | 3 | /** 4 | * This class is about data types in Java 5 | * @author NaveenKhunteta 6 | * 7 | */ 8 | public class DataTypes { 9 | 10 | public static void main(String[] args) { 11 | 12 | //this is my 13 | //first 14 | //java code 15 | 16 | /*this is data types 17 | * and im so happy 18 | */ 19 | 20 | 21 | //data types: 22 | //Integer Family: byte, short, int, long 23 | //Floating family: float, double 24 | //character: char 25 | //boolean : true and false 26 | //String: 27 | 28 | //1. byte: 29 | //size: 1 byte = 8 bits 30 | //range: -128 to 127 31 | byte b = 10; 32 | byte b1 = 20; 33 | byte b2 = 0; 34 | byte b3 = -30; 35 | 36 | System.out.println(b); 37 | System.out.println(b3); 38 | System.out.println(b+b1+b3); 39 | 40 | //2. short: 41 | //size: 2 bytes: 16 bits 42 | //range: -32768 to 32767 43 | short s1 = 10; 44 | short s2 = -1000; 45 | 46 | //3. int: 47 | //size: 4 bytes = 32 bits 48 | //range: -2147483648 to 2147483647 49 | int i = 10; 50 | int total = 20000; 51 | 52 | //4. long: 53 | //size: 8 bytes = 64 bits 54 | //range: will check it 55 | long l = 232323232; 56 | 57 | //5. float: 58 | //size: 4 bytes = 32 bits 59 | //range : around 7 digits after . 60 | float f = 12.33f; 61 | float f1 = (float)23.44; 62 | float f3 = 100;//100.0 63 | System.out.println(f+10); 64 | System.out.println(f3); 65 | 66 | //6. double: 67 | //size: 8 bytes = 64 bits 68 | //range: upto 15 digits after . 69 | double d = 12.33; 70 | double d1 = -34.5555; 71 | 72 | //7. char: 73 | //size: 2 bytes 74 | char c = 'a'; 75 | char c11 = 'b'; 76 | char c1 = '1'; 77 | char c2 = '$'; 78 | 79 | System.out.println(c); 80 | System.out.println(c+c11);//97+98 = 195 81 | //a-z --> 97-122 82 | //A-Z --> 65 - 90 83 | //0-9 --> 48 - 57 84 | 85 | 86 | //8. boolean: 87 | //size: ~ 1 bit 88 | boolean flag = true; 89 | boolean test = false; 90 | 91 | //9. String: is not a data type, its a class 92 | String str = "hello world"; 93 | System.out.println(str); 94 | 95 | String st1 = "100"; 96 | System.out.println(st1+str); 97 | 98 | System.out.println(1000); 99 | System.out.println("hello selenium"); 100 | System.out.println(10+20); 101 | System.out.println("testing" + 100); 102 | System.out.println("hello" + " "+ "world"); 103 | 104 | System.out.print(80+"\n"); 105 | System.out.println(60); 106 | 107 | //System.err.println("some error is coming...."); 108 | 109 | System.out.println(4/2); 110 | System.out.println(9 % 2); 111 | 112 | byte bbb = 065; 113 | System.out.println(bbb); 114 | 115 | //65 = (6 × 8¹) + (5 × 8⁰) = 53 116 | 117 | 118 | } 119 | 120 | } 121 | -------------------------------------------------------------------------------- /src/JavaSessions/Ecomm.java: -------------------------------------------------------------------------------- 1 | package JavaSessions; 2 | 3 | public class Ecomm { 4 | 5 | public static void main(String[] args) { 6 | // TODO Auto-generated method stub 7 | 8 | } 9 | 10 | // Method Overloading: is part of Polymorphism ==> poly + morphism 11 | // Within the same class, when you have different methods with: 12 | // 1. same name 13 | // 2. having different parameters 14 | // 3. the sequence of the params is different 15 | public void search() { 16 | 17 | } 18 | 19 | public void search(String name) { 20 | 21 | } 22 | 23 | public void search(String name, int price) { 24 | 25 | } 26 | 27 | public void search(String name, int price, String color) { 28 | 29 | } 30 | 31 | public void search(String name, String color) { 32 | 33 | } 34 | 35 | public void search(String name, int price, String color, String seller) { 36 | 37 | } 38 | 39 | // 40 | public void payment() { 41 | 42 | } 43 | 44 | public void payment(String UPI) { 45 | 46 | } 47 | 48 | public void payment(String UPI, int otp) { 49 | 50 | } 51 | 52 | public void payment(String UPI, int otp, long ph) { 53 | 54 | } 55 | 56 | public void payment(long cc, int cvv) { 57 | 58 | } 59 | 60 | // 61 | public void login() { 62 | 63 | } 64 | 65 | public void login(String email) { 66 | 67 | } 68 | 69 | public void login(String email, String password) { 70 | 71 | } 72 | 73 | public void login(String email, long ph) { 74 | 75 | } 76 | 77 | public void login(String email, String password, int otp) { 78 | 79 | } 80 | 81 | public void login(String email, String password, String captcha) { 82 | 83 | } 84 | 85 | } 86 | -------------------------------------------------------------------------------- /src/JavaSessions/EmpTest.java: -------------------------------------------------------------------------------- 1 | package JavaSessions; 2 | 3 | public class EmpTest { 4 | 5 | String name; 6 | int age; 7 | boolean status; 8 | double salary; 9 | static String lastName; 10 | 11 | public static void main(String[] args) { 12 | 13 | final int total = 100; 14 | System.out.println(total); 15 | 16 | EmpTest e1 = new EmpTest(); 17 | 18 | System.out.println(e1.name); 19 | System.out.println(e1.age); 20 | System.out.println(e1.status); 21 | System.out.println(e1.salary); 22 | 23 | System.out.println(lastName); 24 | 25 | final int days = 7; 26 | System.out.println(100 * days * 200); 27 | 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/JavaSessions/Employee.java: -------------------------------------------------------------------------------- 1 | package JavaSessions; 2 | 3 | import java.util.ArrayList; 4 | 5 | public class Employee { 6 | 7 | public static void main(String[] args) { 8 | 9 | Employee e1 = new Employee(); 10 | String assets_sheetal[] = e1.getEmployeeAssets("Naveen"); 11 | 12 | System.out.println("total assets: " + assets_sheetal.length); 13 | 14 | for (String s : assets_sheetal) { 15 | System.out.println(s); 16 | } 17 | 18 | System.out.println("------"); 19 | 20 | ArrayList orderList_Tom = e1.getEmpOrders("Naveen"); 21 | System.out.println("total orders: " + orderList_Tom.size()); 22 | for(String s : orderList_Tom){ 23 | System.out.println(s); 24 | } 25 | 26 | } 27 | 28 | // WAM: where we have to pass the emp name and return the employee assets 29 | // array 30 | 31 | public String[] getEmployeeAssets(String empName) { 32 | System.out.println("emp name is : " + empName); 33 | String asset[] = new String[4]; 34 | 35 | if (empName.equals("Sheetal")) { 36 | asset[0] = "Macbook Pro"; 37 | asset[1] = "Mouse"; 38 | asset[2] = "Keyboard"; 39 | asset[3] = "iPhone X"; 40 | } 41 | 42 | else if (empName.equals("Kiran")) { 43 | asset[0] = "Windows Laptop"; 44 | asset[1] = "Mouse"; 45 | asset[2] = "Keyboard"; 46 | asset[3] = "headphone"; 47 | } 48 | 49 | else{ 50 | System.out.println("this employee " + empName + " is not found, please pass the correct name....."); 51 | return null; 52 | } 53 | 54 | return asset; 55 | 56 | } 57 | 58 | public ArrayList getEmpOrders(String empName) { 59 | 60 | System.out.println("getEmpOrders for " + empName); 61 | 62 | ArrayList orderList = new ArrayList(); 63 | 64 | if (empName.equals("Tom")) { 65 | orderList.add("iPhone"); 66 | orderList.add("Laptop"); 67 | orderList.add("Tshirt"); 68 | orderList.add("Shoes"); 69 | } 70 | 71 | else if (empName.equals("Steve")) { 72 | orderList.add("iPhone"); 73 | orderList.add("Laptop"); 74 | } 75 | 76 | else{ 77 | System.out.println("this employee " + empName + " is not found, please pass the correct name....."); 78 | } 79 | 80 | return orderList; 81 | } 82 | 83 | } 84 | -------------------------------------------------------------------------------- /src/JavaSessions/FinalizeMethodConcept.java: -------------------------------------------------------------------------------- 1 | package JavaSessions; 2 | 3 | public class FinalizeMethodConcept { 4 | int age; 5 | 6 | public static void main(String[] args) { 7 | 8 | String s = new String("Naveen"); 9 | 10 | FinalizeMethodConcept obj = new FinalizeMethodConcept(); 11 | obj = null; 12 | s = null; 13 | 14 | System.gc(); 15 | System.out.println("Done!!!"); 16 | 17 | } 18 | 19 | @Override 20 | public void finalize() { 21 | System.out.println("this is my finalize method...."); 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /src/JavaSessions/FinallyConcept.java: -------------------------------------------------------------------------------- 1 | package JavaSessions; 2 | 3 | public class FinallyConcept { 4 | 5 | public static void main(String[] args) { 6 | 7 | // associated with try-catch 8 | // finally is block - it will be executed all the time doesnt matter 9 | // exception is coming or not 10 | 11 | int p = 10; 12 | 13 | try { 14 | System.out.println("this is before exception..."); 15 | System.out.println("DB Connection -- trying to stablish"); 16 | System.out.println("DB Connection -- is DONE"); 17 | 18 | int z = p / 0; 19 | } catch (ArithmeticException e) { 20 | System.out.println("some exceptpn is coming...."); 21 | } finally { 22 | System.out.println("executing finally block...."); 23 | System.out.println("flush / close the connection...."); 24 | } 25 | 26 | 27 | int m = getMarks("Ali"); 28 | System.out.println(m); 29 | } 30 | 31 | 32 | 33 | public static int getMarks(String name) { 34 | 35 | try { 36 | if (name.equals("Neha")) { 37 | return 100; 38 | } else if (name.equals("Sheetal")) { 39 | return 90; 40 | } else if (name.equals("Ali")) { 41 | int i = 9/0; 42 | return 95; 43 | } else { 44 | return -1; 45 | } 46 | 47 | } catch (Exception e) { 48 | return -2; 49 | } 50 | 51 | finally { 52 | System.out.println("Bye..."); 53 | //return -3; 54 | } 55 | 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /src/JavaSessions/FunctionsInJava.java: -------------------------------------------------------------------------------- 1 | package JavaSessions; 2 | 3 | public class FunctionsInJava { 4 | 5 | //function can not be created inside a function 6 | 7 | 8 | public static void main(String[] args) { 9 | 10 | FunctionsInJava obj = new FunctionsInJava(); 11 | obj.test(); 12 | obj.printName(); 13 | obj.total(); 14 | int s = obj.add(); 15 | System.out.println(s+100+20); 16 | 17 | System.out.println(obj.add()); 18 | 19 | String n = obj.getTrainerName(); 20 | System.out.println("trainer name is: " + n); 21 | 22 | int s1 = obj.getSum(10, 20); 23 | System.out.println(s1+5+100); 24 | 25 | int s2 = obj.getSum(40, 90); 26 | System.out.println(s2); 27 | 28 | String capName = obj.getCapitalName("India"); 29 | System.out.println(capName); 30 | 31 | capName = obj.getCapitalName("Russia"); 32 | System.out.println(capName); 33 | 34 | int m = obj.getStudnetMarks("Tom"); 35 | System.out.println(m); 36 | 37 | if(obj.launchBrowser("IE")){ 38 | System.out.println("start my test casessss"); 39 | } 40 | else{ 41 | System.out.println("Sorry there is no browser....."); 42 | } 43 | } 44 | 45 | //1. no input and no return 46 | //void -- no return (can not return any value) 47 | public void test(){ 48 | System.out.println("test method..."); 49 | } 50 | 51 | public void printName(){ 52 | System.out.println("naveen"); 53 | } 54 | 55 | public void total(){ 56 | System.out.println("total method"); 57 | int a = 10; 58 | int b = 20; 59 | int c = a+b; 60 | System.out.println(c); 61 | } 62 | 63 | //2. no input and some return: 64 | public int add(){ 65 | System.out.println("add method"); 66 | int x = 100; 67 | int y = 200; 68 | int z = x+y;//300 69 | 70 | return z; 71 | } 72 | 73 | public String getTrainerName(){ 74 | System.out.println("get trainer name"); 75 | String name = "Naveen"; 76 | return name; 77 | } 78 | 79 | //3. some input and some return: 80 | 81 | public int getSum(int a, int b){ 82 | System.out.println("get sum method...."); 83 | int sum = a+b; 84 | return sum; 85 | } 86 | 87 | //WAP to get the capital name of the country 88 | public String getCapitalName(String countryName){ 89 | 90 | System.out.println("getting capital name for " + countryName); 91 | 92 | if(countryName.equals("India")){ 93 | return "New Delhi"; 94 | } 95 | 96 | else if(countryName.equals("USA")){ 97 | return "Wahington DC"; 98 | } 99 | 100 | else if(countryName.equals("UK")){ 101 | return "London"; 102 | } 103 | 104 | else{ 105 | System.out.println("this country is not found..." + countryName); 106 | return null; 107 | } 108 | 109 | } 110 | 111 | 112 | //WAP where i'll be passing a student Name(String) and then function should return the marks(int) of that student. 113 | public int getStudnetMarks(String name){ 114 | int marks = 0; 115 | System.out.println("getting the marks for " + name); 116 | 117 | if(name.equals("Mohan")){ 118 | marks = 90; 119 | } 120 | else if(name.equals("Kanika")){ 121 | marks = 95; 122 | } 123 | else if(name.equals("Pratik")){ 124 | marks = 100; 125 | } 126 | else if(name.equals("Naveen")){ 127 | marks = 10; 128 | } 129 | else{ 130 | System.out.println("student not found :" + name); 131 | return -1; 132 | } 133 | 134 | return marks; 135 | } 136 | 137 | 138 | //WAP : where we will pass the browserName, and launch the browser and return boolean: 139 | 140 | public boolean launchBrowser(String browserName){ 141 | System.out.println("launching browser: " + browserName); 142 | boolean flag = false; 143 | 144 | switch (browserName) { 145 | case "chrome": 146 | System.out.println("launching chrome"); 147 | flag = true; 148 | break; 149 | case "firefox": 150 | System.out.println("launching firefox"); 151 | flag = true; 152 | break; 153 | case "safari": 154 | System.out.println("launching safari"); 155 | flag = true; 156 | break; 157 | 158 | default: 159 | System.out.println("browse is not found: " + browserName); 160 | break; 161 | } 162 | 163 | return flag; 164 | } 165 | 166 | 167 | 168 | 169 | 170 | } 171 | -------------------------------------------------------------------------------- /src/JavaSessions/HashMapConcept.java: -------------------------------------------------------------------------------- 1 | package JavaSessions; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | 6 | public class HashMapConcept { 7 | 8 | public static void main(String[] args) { 9 | 10 | 11 | //Collection -- dynamic 12 | //stores the values : key-value pair 13 | //can have only one null key 14 | //can have any number of null values 15 | 16 | Map EmpMap = new HashMap(); 17 | 18 | EmpMap.put("name", "Tom"); 19 | EmpMap.put("ID", "101"); 20 | EmpMap.put("city", "Bangalore"); 21 | EmpMap.put("country", "IN"); 22 | EmpMap.put(null, "1000"); 23 | EmpMap.put(null, "2000"); 24 | EmpMap.put("age", null); 25 | EmpMap.put("phone", null); 26 | EmpMap.put("country", "UK"); 27 | 28 | 29 | System.out.println(EmpMap.get("name")); 30 | System.out.println(EmpMap.get("country")); 31 | System.out.println(EmpMap.get("salary"));//null 32 | 33 | System.out.println(EmpMap.get(null)); 34 | System.out.println(EmpMap.get("age")); 35 | 36 | //entrySet: to fetch all keys-values: 37 | for(Map.Entry entry : EmpMap.entrySet()) { 38 | System.out.println("Key = " + entry.getKey() + " value = " + entry.getValue()); 39 | } 40 | 41 | System.out.println("----"); 42 | 43 | //keySet(): for getting the keys: 44 | for(String s : EmpMap.keySet()) { 45 | System.out.println("key = " + s); 46 | } 47 | 48 | System.out.println("----"); 49 | 50 | 51 | //values(): for getting the values: 52 | for(String v: EmpMap.values()) { 53 | System.out.println("value = " + v); 54 | } 55 | System.out.println("----"); 56 | 57 | 58 | //Lambda: 59 | EmpMap.forEach((k,v) -> System.out.println("key = " + k + " value = " + v)); 60 | 61 | 62 | 63 | } 64 | 65 | } 66 | -------------------------------------------------------------------------------- /src/JavaSessions/IncrementalAndDecrementalOperators.java: -------------------------------------------------------------------------------- 1 | package JavaSessions; 2 | 3 | public class IncrementalAndDecrementalOperators { 4 | 5 | public static void main(String[] args) { 6 | 7 | 8 | //System.out.println("hello " + ('a' + 'b')); 9 | 10 | //1. post increment: ++ 11 | int a = 1; 12 | int b = a++; //post increment 13 | System.out.println(a);//2 14 | System.out.println(b);//1 15 | 16 | int m = -1; 17 | int n = m++; //post increment 18 | 19 | System.out.println(m);//0 20 | System.out.println(n);//-1 21 | 22 | //2. pre increment: 23 | int p = 1; 24 | int q = ++p; //pre increment 25 | System.out.println(p);//2 26 | System.out.println(q);//2 27 | 28 | int c = -99; 29 | int d = ++c; 30 | System.out.println(c);//-98 31 | System.out.println(d);//-98 32 | 33 | //3. post decrement: -- 34 | int r = 2; 35 | int e = r--; //post decrement 36 | System.out.println(r);//1 37 | System.out.println(e);//2 38 | 39 | //4. pre decrement: 40 | int s = 2; 41 | int f = --s; 42 | System.out.println(s);//1 43 | System.out.println(f);//1 44 | 45 | int v = 2; 46 | System.out.println(v++); 47 | System.out.println(v); 48 | 49 | 50 | 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /src/JavaSessions/Login.java: -------------------------------------------------------------------------------- 1 | package JavaSessions; 2 | 3 | 4 | public class Login { 5 | 6 | public static void main(String[] args) { 7 | 8 | Login l = new Login(); 9 | l.login(); 10 | l.search(); 11 | 12 | } 13 | 14 | public void login() { 15 | profile(); 16 | test(); 17 | } 18 | 19 | public void profile() { 20 | search(); 21 | addToCart(); 22 | payment(); 23 | } 24 | 25 | public void search() { 26 | addToCart(); 27 | } 28 | 29 | public void addToCart() { 30 | payment(); 31 | } 32 | 33 | public void payment() { 34 | 35 | } 36 | 37 | public void getOrder() { 38 | 39 | } 40 | 41 | public static void test() { 42 | price(); 43 | } 44 | 45 | public static void price() { 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /src/JavaSessions/LoopsConcept.java: -------------------------------------------------------------------------------- 1 | package JavaSessions; 2 | 3 | public class LoopsConcept { 4 | 5 | public static void main(String[] args) { 6 | 7 | 8 | //1 to 10: 9 | //loops: 10 | //1. while: 11 | 12 | int i = 1; //Initialization 13 | while(i<=10){ //Conditional 14 | System.out.println(i);//1 2 3 4 5 .... 10 15 | i++; //incremental/decremental 16 | } 17 | 18 | System.out.println("----------"); 19 | 20 | //2. for loop: 21 | //1 to 10: 22 | for(int k=1; k<=10; k++){ 23 | System.out.println(k);//1 2 3 4 5....10 24 | } 25 | 26 | // for( ; ; ){ 27 | // System.out.println("Welcome to Taz Hotel"); 28 | // } 29 | 30 | System.out.println("----------"); 31 | 32 | //even numbers: 0 2 4 6 8 10 33 | for(int even=0; even<=10; even=even+2){ 34 | System.out.println(even);//0 2 4 6 8 10 35 | } 36 | 37 | System.out.println("----------"); 38 | 39 | //odd numbers: 1 3 5 7 9 40 | for(int odd=1; odd<10; odd=odd+2){ 41 | System.out.println(odd);//1 3 5 7 9 42 | } 43 | 44 | // 45 | for(int p=1; p<=10;){ 46 | System.out.println(p); 47 | //p++; 48 | p=p+1; 49 | } 50 | System.out.println("----------"); 51 | 52 | 53 | // 54 | for(int h=1; h<=100; h++){ 55 | System.out.println(h); 56 | if(h % 5 == 0){ 57 | System.out.println("hiiii"); 58 | } 59 | } 60 | 61 | System.out.println("----------"); 62 | 63 | //a to z: 64 | for(char c ='a' ; c<='z'; c++){ 65 | System.out.println(c); 66 | } 67 | 68 | 69 | System.out.println("----------"); 70 | 71 | for(byte b=1; b<=5; b++){ 72 | System.out.println(b); 73 | } 74 | 75 | System.out.println("----------"); 76 | 77 | for(double d=1.1; d<10; d++){ 78 | System.out.println(d); 79 | } 80 | 81 | System.out.println("----------"); 82 | 83 | for(String st = "hello"; st.equals("hello");){ 84 | System.out.println(st); 85 | 86 | } 87 | 88 | System.out.println("----------"); 89 | 90 | 91 | //3. do-while: 92 | int n = 1; 93 | do{ 94 | System.out.println(n);//12345678910 95 | n++; 96 | } 97 | while(n<=10); 98 | 99 | 100 | } 101 | 102 | } 103 | -------------------------------------------------------------------------------- /src/JavaSessions/MainMethodOverloading.java: -------------------------------------------------------------------------------- 1 | package JavaSessions; 2 | 3 | public class MainMethodOverloading { 4 | 5 | public static void main(String a[]) { 6 | System.out.println("Hello Naveen"); 7 | 8 | main(10, 20); 9 | 10 | login(9999999, 999); 11 | } 12 | 13 | public static void main(int i) { 14 | System.out.println(i); 15 | } 16 | 17 | public static void main(int i, int k) { 18 | System.out.println(i + k); 19 | } 20 | 21 | public static void main(int i, String p) { 22 | System.out.println(i + p); 23 | } 24 | 25 | // can we overload static methods? 26 | public static void login() { 27 | 28 | } 29 | 30 | public static void login(long ph) { 31 | 32 | } 33 | 34 | public static void login(long ph, int otp) { 35 | 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /src/JavaSessions/MethodOverloading.java: -------------------------------------------------------------------------------- 1 | package JavaSessions; 2 | 3 | public class MethodOverloading { 4 | 5 | public static void main(String[] args) { 6 | 7 | MethodOverloading obj = new MethodOverloading(); 8 | obj.test(); 9 | obj.test(10); 10 | obj.test(20, "naveen"); 11 | 12 | } 13 | 14 | //Method Overloading: is part of Polymorphism ==> poly + morphism 15 | //Within the same class, when you have different methods with: 16 | //1. same name 17 | //2. having different parameters 18 | //3. the sequence of the params is different 19 | 20 | //Compile time Polymorphism 21 | 22 | public void test() { 23 | System.out.println("test method..."); 24 | } 25 | 26 | public void test(int i) { 27 | System.out.println(i); 28 | } 29 | 30 | public void test(int k, int p) { 31 | System.out.println(k+""+p); 32 | } 33 | 34 | public void test(int k, String p) { 35 | System.out.println(k+p); 36 | 37 | } 38 | 39 | public void test(String p, int k) { 40 | System.out.println(p+k); 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /src/JavaSessions/Person.java: -------------------------------------------------------------------------------- 1 | package JavaSessions; 2 | 3 | public class Person { 4 | 5 | String name; 6 | int age; 7 | char gender; 8 | 9 | public static void main(String[] args) { 10 | 11 | Person p1 = new Person(); 12 | p1.name = "Kiran"; 13 | p1.age = 30; 14 | p1.gender = 'm'; 15 | 16 | Person p2 = new Person(); 17 | p2.name = "Priya"; 18 | p2.age = 40; 19 | p2.gender = 'f'; 20 | 21 | Person p3 = new Person(); 22 | p3.name = "Ali"; 23 | p3.age = 35; 24 | p3.gender = 'm'; 25 | 26 | System.out.println(p1.name + " " + p1.age + " " + p1.gender ); 27 | System.out.println(p2.name + " " + p2.age + " " + p2.gender ); 28 | System.out.println(p3.name + " " + p3.age + " " + p3.gender ); 29 | 30 | p1 = p2; 31 | p2 = p3; 32 | 33 | System.out.println(p1.name + " " + p1.age + " " + p1.gender ); 34 | System.out.println(p2.name + " " + p2.age + " " + p2.gender ); 35 | System.out.println(p3.name + " " + p3.age + " " + p3.gender ); 36 | 37 | p3 = p1; 38 | System.out.println(p1.name + " " + p1.age + " " + p1.gender ); 39 | System.out.println(p2.name + " " + p2.age + " " + p2.gender ); 40 | System.out.println(p3.name + " " + p3.age + " " + p3.gender ); 41 | 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /src/JavaSessions/StringConcatenation.java: -------------------------------------------------------------------------------- 1 | package JavaSessions; 2 | 3 | public class StringConcatenation { 4 | 5 | public static void main(String[] args) { 6 | 7 | double c = 12.33; 8 | double d = 23.33; 9 | 10 | int a = 100; 11 | int b = 200; 12 | 13 | String x = "Hello"; 14 | String y = "Testing"; 15 | 16 | System.out.println(a+b); 17 | System.out.println(c+d); 18 | 19 | System.out.println(x+y); 20 | 21 | System.out.println(a+b+x+y); 22 | 23 | System.out.println(x+y+a+b);//HelloTesting100200 24 | 25 | System.out.println(x+y+(a+b)); 26 | 27 | System.out.println(x+y+c+d+a+b); 28 | 29 | System.out.println("the value of a is: " +a); 30 | System.out.println("the value of b is: " +b); 31 | System.out.println("the sum of a and b is: " + (a+b)); 32 | 33 | System.out.println(c+d+(x+y)+a+b); 34 | System.out.println(c+d+x+y+(a+b)); 35 | 36 | 37 | int i = 4/2; 38 | System.out.println(i); 39 | System.out.println(4/2); 40 | System.out.println(5/2);//2.5 --> 2 41 | System.out.println(5.0/2);//2.5 42 | System.out.println(5/2.0);//2.5 43 | System.out.println(5.0/2.0);//2.5 44 | 45 | //float k = (float) (9/2.0); 46 | float k = 9/2.0f; 47 | System.out.println(k); 48 | 49 | // int p = 9/0; //0/0 //java.lang.ArithmeticException: / by zero 50 | // System.out.println(p); 51 | 52 | int m = 0/100; 53 | System.out.println(m); 54 | 55 | 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /src/JavaSessions/StringManipulation.java: -------------------------------------------------------------------------------- 1 | package JavaSessions; 2 | 3 | public class StringManipulation { 4 | 5 | public static void main(String[] args) { 6 | 7 | 8 | String str = "Hello This is my first java code and I am so happy"; 9 | 10 | System.out.println(str.length());//44 11 | System.out.println("Li=" + 0); 12 | System.out.println("Hi = " + (str.length()-1)); 13 | 14 | System.out.println(str.charAt(5)); 15 | System.out.println(str.charAt(0)); 16 | System.out.println(str.charAt(43)); 17 | //System.out.println(str.charAt(44));//StringIndexOutOfBoundsException 18 | 19 | System.out.println(str.indexOf("m")); 20 | System.out.println(str.indexOf("i"));//1st occurrence of i 21 | System.out.println(str.indexOf("i", str.indexOf("i")+1)); //2nd occurrence of i 22 | 23 | System.out.println(str.indexOf("java"));//23 24 | System.out.println(str.indexOf("naveen"));//-1 25 | 26 | String messg = "welcome naveen"; 27 | if(messg.indexOf("naveen") == 8) { 28 | System.out.println("correct welcome mesg"); 29 | } 30 | else { 31 | System.out.println("in correct welcome mesg"); 32 | } 33 | 34 | //trim: 35 | String s = " hello world "; 36 | System.out.println(s.trim()); 37 | 38 | //replace: 39 | System.out.println(s.trim().replace(" ", "")); 40 | 41 | String dob = "01-01-1990"; // 01/01/1990 42 | System.out.println(dob.replace("-", "/")); 43 | 44 | //upper/lower cases: 45 | String s1 = "this is my java code"; 46 | System.out.println(s1.toUpperCase()); 47 | 48 | String s2 = "HELLO WELCOME TO TESTING WORLD"; 49 | System.out.println(s2.toLowerCase()); 50 | 51 | //contains: 52 | String s3 = "Your browser is chrome"; 53 | System.out.println(s3.contains("chrome"));//true 54 | 55 | String browser = "chrome"; 56 | if(browser.contains("chrome")) { 57 | System.out.println("launch chrome browser"); 58 | } 59 | 60 | //String Comparisons: 61 | //.equals() 62 | 63 | System.out.println(browser.equals("chrome")); 64 | System.out.println(browser.equalsIgnoreCase("chrome")); 65 | 66 | String f1 = "Hello World"; 67 | String f2 = "Hello World "; 68 | System.out.println(f1.equals(f2)); 69 | System.out.println(f1.equalsIgnoreCase(f2)); 70 | System.out.println(f1.equalsIgnoreCase(f2.trim())); 71 | 72 | 73 | System.out.println(f1.concat(f2)); 74 | System.out.println(f1+f2); 75 | 76 | //split: 77 | String lang = "Java;Python;JavaScript;Ruby"; 78 | 79 | String language[] = lang.split(";"); 80 | 81 | System.out.println(language.length); 82 | System.out.println(language[0]); 83 | 84 | for(String ele : language) { 85 | System.out.println(ele); 86 | } 87 | 88 | System.out.println("----"); 89 | 90 | for(int i=0; i" + tester[0]); 106 | System.out.println("1st--->" + tester[1]); 107 | System.out.println("2nd--->" + tester[2]); 108 | System.out.println("3rd--->" + tester[3]); 109 | 110 | //SubString: 111 | String main = "Your total amount is 3000"; 112 | System.out.println(main.substring(5)); 113 | System.out.println(main.substring(5, 12)); 114 | 115 | System.out.println(main.substring(main.indexOf("is")+3, main.length())); 116 | 117 | System.out.println(main.substring(main.indexOf("is")+3)); 118 | 119 | String amount = main.substring(main.indexOf("is")+3, main.length()); 120 | System.out.println(amount+50+10);//30005010 121 | System.out.println(amount+(50+10));//300060 122 | //3060 123 | 124 | //String to int: using ParseInt from Integer class: 125 | int amountVal = Integer.parseInt(amount); //3000 126 | System.out.println(amountVal + 50 + 10); 127 | 128 | //String enroll = "Your transaction id is 12345 please enroll"; 129 | 130 | 131 | } 132 | 133 | } 134 | -------------------------------------------------------------------------------- /src/JavaSessions/TimeCompexity.java: -------------------------------------------------------------------------------- 1 | package JavaSessions; 2 | 3 | public class TimeCompexity { 4 | 5 | public static void main(String[] args) { 6 | 7 | // O(n) 8 | // O(1) 9 | // Big O(n) 10 | 11 | int i = 10; // O(1) 12 | System.out.println(i);// O(1) 13 | 14 | // single for loop: //O(n) 15 | for (int k = 1; k <= 10; k++) { 16 | System.out.println(k); 17 | } 18 | 19 | // 1 + n + n + n ==> 1+3n ==> 3n ==> n ==> O(n) 20 | // linear equation 21 | 22 | System.out.println("----------"); 23 | // two for loops: 24 | // 00 01 02 03 04 05 25 | // 10 11 12 13 14 15 26 | // two for loops: 27 | 28 | for (int m = 0; m < 10; m++) { 29 | 30 | for (int n = 0; n < 10; n++) { 31 | 32 | System.out.print(m + "" + n + " "); 33 | 34 | } 35 | 36 | System.out.println(); 37 | 38 | } 39 | // (1 + n + n + n) (1+ n + n + n) ==> (1+3n)(1+3n) ==> 1+3n+3n+9n^2 ==> 9n^2+6n+1 ==> 9n^2+6n ==> 3(3n^2+2n) 40 | // ==> n^2+n ==> n(n+1) ==> n^2 41 | //Quadratic equation ==> O(n^2) 42 | 43 | //O(n^k) ; k>=0 44 | 45 | 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /src/OOP_Abstract/Cloud.java: -------------------------------------------------------------------------------- 1 | package OOP_Abstract; 2 | 3 | public abstract class Cloud { 4 | 5 | //0% abstraction --No abstract methods 6 | //100% abstraction -- all methods are abstract in nature 7 | //partial abstraction --> mixture of abs + non abs methods. 8 | //0 to 100% abstraction can be achieved by Abstract classes 9 | 10 | public void service() { 11 | 12 | } 13 | 14 | public void deploy() { 15 | 16 | } 17 | 18 | public void build() { 19 | 20 | } 21 | 22 | 23 | 24 | 25 | } 26 | -------------------------------------------------------------------------------- /src/OOP_Abstract/LoginPage.java: -------------------------------------------------------------------------------- 1 | package OOP_Abstract; 2 | 3 | public class LoginPage extends Page{ 4 | 5 | public LoginPage() { 6 | System.out.println("LP -- const..."); 7 | } 8 | 9 | @Override 10 | public void title() { 11 | System.out.println("LP - Title"); 12 | } 13 | 14 | @Override 15 | public void url() { 16 | System.out.println("LP - URL"); 17 | } 18 | 19 | public void forgotPwd() { 20 | System.out.println("LP - ForgotPWD"); 21 | } 22 | 23 | 24 | 25 | 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/OOP_Abstract/Page.java: -------------------------------------------------------------------------------- 1 | package OOP_Abstract; 2 | 3 | public abstract class Page { 4 | 5 | //can not create the object of Abstract class 6 | 7 | //may have some abstract methods: 8 | 9 | //can I create the constructor of page class? -- YES 10 | public Page() { 11 | System.out.println("Page Const...."); 12 | } 13 | 14 | public abstract void title();//abstract methods 15 | public abstract void url(); 16 | 17 | //can have non abstract method? -->yes 18 | public void timeOut() { 19 | System.out.println("page -- time out"); 20 | } 21 | 22 | public static void logo() { 23 | System.out.println("PAGE -- LOGO"); 24 | } 25 | 26 | 27 | 28 | 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/OOP_Abstract/TestPage.java: -------------------------------------------------------------------------------- 1 | package OOP_Abstract; 2 | 3 | public class TestPage { 4 | 5 | public static void main(String[] args) { 6 | 7 | LoginPage lp = new LoginPage(); 8 | 9 | lp.title(); 10 | lp.url(); 11 | lp.timeOut(); 12 | Page.logo(); 13 | lp.forgotPwd(); 14 | 15 | //top casting: 16 | Page p = new LoginPage(); 17 | p.title(); 18 | p.url(); 19 | p.timeOut(); 20 | 21 | 22 | 23 | 24 | 25 | 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /src/OOP_Encapsulation/AmazonTest.java: -------------------------------------------------------------------------------- 1 | package OOP_Encapsulation; 2 | 3 | public class AmazonTest { 4 | 5 | public static void main(String[] args) { 6 | 7 | LoginPage lp = new LoginPage("admin@gmail.com", "admin"); 8 | 9 | // lp.setUsername("cust@gmail.com"); 10 | // lp.setPassword("cust@123"); 11 | 12 | lp.doLogin(lp.getUsername(), lp.getPassword()); 13 | 14 | // lp.setUsername("seller@gmail.com"); 15 | // lp.setPassword("seller@123"); 16 | 17 | lp.doLogin(lp.getUsername(), lp.getPassword()); 18 | 19 | 20 | 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/OOP_Encapsulation/Browser.java: -------------------------------------------------------------------------------- 1 | package OOP_Encapsulation; 2 | 3 | public class Browser { 4 | 5 | public void launchBrowser() { 6 | System.out.println("launching browser....."); 7 | checkBrowserVersion(); 8 | checkBrowserOSVersion(); 9 | interactWithOSServices(); 10 | checkRAMSpace(); 11 | System.out.println("chrome browser is launched...."); 12 | 13 | } 14 | 15 | public void checkBrowserVersion() { 16 | System.out.println("checkBrowserVersion..."); 17 | } 18 | 19 | public void checkBrowserOSVersion() { 20 | System.out.println("checkBrowser OS Version..."); 21 | } 22 | 23 | public void interactWithOSServices() { 24 | System.out.println("checkBrowserVersion..."); 25 | } 26 | 27 | public void checkRAMSpace() { 28 | System.out.println("check RAM space...."); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/OOP_Encapsulation/BrowserUser.java: -------------------------------------------------------------------------------- 1 | package OOP_Encapsulation; 2 | 3 | public class BrowserUser { 4 | 5 | public static void main(String[] args) { 6 | 7 | Browser br = new Browser(); 8 | 9 | br.launchBrowser(); 10 | 11 | 12 | 13 | 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /src/OOP_Encapsulation/Company.java: -------------------------------------------------------------------------------- 1 | package OOP_Encapsulation; 2 | 3 | public class Company { 4 | 5 | private String name; 6 | private int totalEmployee; 7 | private int sharePrice; 8 | 9 | public String getName() { 10 | return name; 11 | } 12 | 13 | public void setName(String name) { 14 | this.name = name; 15 | } 16 | 17 | public int getTotalEmployee() { 18 | return totalEmployee; 19 | } 20 | 21 | public void setTotalEmployee(int totalEmployee) { 22 | this.totalEmployee = totalEmployee; 23 | } 24 | 25 | public int getSharePrice() { 26 | return sharePrice; 27 | } 28 | 29 | public void setSharePrice(int sharePrice) { 30 | this.sharePrice = sharePrice; 31 | } 32 | 33 | 34 | //methods: 35 | private void getPrivacyPolicy(){ 36 | System.out.println("getPrivacyPolicy..."); 37 | } 38 | 39 | public void getPolicyInfo(){ 40 | getPrivacyPolicy(); 41 | } 42 | 43 | 44 | } 45 | -------------------------------------------------------------------------------- /src/OOP_Encapsulation/EmpTest.java: -------------------------------------------------------------------------------- 1 | package OOP_Encapsulation; 2 | 3 | public class EmpTest { 4 | 5 | 6 | public static void main(String a[]){ 7 | Employee e1 = new Employee(); 8 | 9 | e1.setName("Tom"); 10 | System.out.println(e1.getName()); 11 | 12 | e1.setAge(30); 13 | System.out.println(e1.getAge()); 14 | 15 | Company c1 = new Company(); 16 | c1.setName("IBM"); 17 | System.out.println(c1.getName()); 18 | 19 | c1.getPolicyInfo(); 20 | 21 | 22 | 23 | 24 | } 25 | 26 | 27 | 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/OOP_Encapsulation/Employee.java: -------------------------------------------------------------------------------- 1 | package OOP_Encapsulation; 2 | 3 | public class Employee { 4 | // data members: (non static) class vars + class methods 5 | //data hiding -- Encapsulation 6 | //hiding the private data members of class and give the access via public getter/setters methods 7 | private String name; 8 | private int id; 9 | private int age; 10 | private double salary; 11 | 12 | // getter and setter methods: (public methods) 13 | public void setName(String name) { 14 | this.name = name; 15 | } 16 | 17 | public String getName() { 18 | return name; 19 | } 20 | 21 | public int getId() { 22 | return id; 23 | } 24 | 25 | public void setId(int id) { 26 | this.id = id; 27 | } 28 | 29 | public int getAge() { 30 | return age; 31 | } 32 | 33 | public void setAge(int age) { 34 | this.age = age; 35 | } 36 | 37 | public double getSalary() { 38 | return salary; 39 | } 40 | 41 | public void setSalary(double salary) { 42 | this.salary = salary; 43 | } 44 | 45 | public static void main(String a[]) { 46 | Employee e1 = new Employee(); 47 | e1.name = "Tom"; 48 | System.out.println(e1.name); 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /src/OOP_Encapsulation/LoginPage.java: -------------------------------------------------------------------------------- 1 | package OOP_Encapsulation; 2 | 3 | public class LoginPage { 4 | 5 | private String username; 6 | private String password; 7 | 8 | public LoginPage(String username, String password){ 9 | this.username = username; 10 | this.password = password; 11 | } 12 | 13 | public String getUsername() { 14 | return username; 15 | } 16 | 17 | // public void setUsername(String username) { 18 | // this.username = username; 19 | // } 20 | 21 | public String getPassword() { 22 | return password; 23 | } 24 | 25 | // public void setPassword(String password) { 26 | // this.password = password; 27 | // } 28 | 29 | 30 | public void doLogin(String un, String pwd){ 31 | System.out.println("login to app with " + un + " and " + pwd); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /src/OOP_Inheritance/Audi.java: -------------------------------------------------------------------------------- 1 | package OOP_Inheritance; 2 | 3 | public class Audi extends Car{ 4 | 5 | public void theftSafety() { 6 | System.out.println("Audi -- theft safety"); 7 | } 8 | 9 | 10 | 11 | 12 | } 13 | -------------------------------------------------------------------------------- /src/OOP_Inheritance/BMW.java: -------------------------------------------------------------------------------- 1 | package OOP_Inheritance; 2 | 3 | public class BMW extends Car{ 4 | 5 | //Method Overriding: 6 | //is a poly+morphism ==> RunTime PolyMorphism 7 | //when you have a method in parent class with the same name and same number of params 8 | //also available in child class -- is called Method Overriding 9 | //static method can not be overridden 10 | 11 | @Override 12 | public void start() { 13 | System.out.println("BMW -- start"); 14 | } 15 | 16 | @Override 17 | public void engine() { 18 | System.out.println("BMW -- engine"); 19 | } 20 | 21 | @Override 22 | public String price() { 23 | System.out.println("Car -- price"); 24 | return "BMW price return"; 25 | } 26 | 27 | public void autoParking() { 28 | System.out.println("BMW -- auto parking"); 29 | } 30 | 31 | 32 | public static void wheels() { 33 | System.out.println("BMW -- Wheels"); 34 | } 35 | 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/OOP_Inheritance/Car.java: -------------------------------------------------------------------------------- 1 | package OOP_Inheritance; 2 | 3 | public class Car extends Vehicle{ 4 | 5 | 6 | public String price() { 7 | System.out.println("Car -- price"); 8 | return "Car Price is 10L"; 9 | } 10 | 11 | public void start() { 12 | System.out.println("Car -- start"); 13 | } 14 | 15 | public void stop() { 16 | System.out.println("Car -- stop"); 17 | } 18 | 19 | public void refuel() { 20 | System.out.println("Car -- refuel"); 21 | } 22 | 23 | public static void wheels() { 24 | System.out.println("Car -- Wheels"); 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/OOP_Inheritance/CarTest.java: -------------------------------------------------------------------------------- 1 | package OOP_Inheritance; 2 | 3 | public class CarTest { 4 | 5 | public static void main(String[] args) { 6 | 7 | 8 | BMW b = new BMW(); 9 | b.refuel();//Inherited from Car 10 | b.stop();//Inherited from Car 11 | 12 | b.start();//Overridden method 13 | 14 | b.autoParking(); //independent method of BMW 15 | b.engine(); 16 | 17 | BMW.wheels(); 18 | 19 | Car c = new Car(); 20 | c.start(); 21 | c.stop(); 22 | c.refuel(); 23 | c.engine(); 24 | Car.wheels(); 25 | 26 | //Top Casting: 27 | Car c1 = new BMW();//child object can be referred by parent class ref variable 28 | c1.start(); 29 | c1.stop(); 30 | c1.refuel(); 31 | //ref type check 32 | 33 | Vehicle v1 = new BMW(); 34 | v1.engine(); 35 | 36 | //Down Casting: 37 | //BMW b1 = (BMW) new Car();//ClassCastException 38 | 39 | 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/OOP_Inheritance/Truck.java: -------------------------------------------------------------------------------- 1 | package OOP_Inheritance; 2 | 3 | public class Truck { 4 | 5 | public void heavyLoad() { 6 | System.out.println("Truck -- heavy Load"); 7 | } 8 | 9 | 10 | 11 | } 12 | -------------------------------------------------------------------------------- /src/OOP_Inheritance/Vehicle.java: -------------------------------------------------------------------------------- 1 | package OOP_Inheritance; 2 | 3 | public class Vehicle { 4 | 5 | public void engine() { 6 | System.out.println("Vehicle -- engine"); 7 | } 8 | 9 | 10 | 11 | 12 | } 13 | -------------------------------------------------------------------------------- /src/OOP_Interface/CentralizedHospital.java: -------------------------------------------------------------------------------- 1 | package OOP_Interface; 2 | 3 | public class CentralizedHospital { 4 | 5 | public void pathalogy() { 6 | System.out.println("CentralizedHospital -- pathalogy"); 7 | } 8 | 9 | 10 | 11 | } 12 | -------------------------------------------------------------------------------- /src/OOP_Interface/FHTrust.java: -------------------------------------------------------------------------------- 1 | package OOP_Interface; 2 | 3 | public class FHTrust { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /src/OOP_Interface/FortisHospital.java: -------------------------------------------------------------------------------- 1 | package OOP_Interface; 2 | 3 | public class FortisHospital extends CentralizedHospital 4 | implements USMedical, UKMedical, IndianMedical { 5 | 6 | // USMedical 7 | @Override 8 | public void orthoServices() { 9 | System.out.println("FH -- orthoServices"); 10 | } 11 | 12 | @Override 13 | public void physioServices() { 14 | System.out.println("FH -- physioServices"); 15 | } 16 | 17 | @Override 18 | public void emergencyServices() { 19 | System.out.println("FH -- emergencyServices"); 20 | } 21 | 22 | @Override 23 | public void audiologyServices() { 24 | System.out.println("FH -- audiologyServices"); 25 | } 26 | 27 | // UkMedical 28 | @Override 29 | public void ENTServices() { 30 | System.out.println("FH -- ENTServices"); 31 | 32 | } 33 | 34 | @Override 35 | public void pediaServices() { 36 | System.out.println("FH -- pediaServices"); 37 | 38 | } 39 | 40 | // IndianMedical 41 | @Override 42 | public void oncologyServices() { 43 | System.out.println("FH -- oncologyServices"); 44 | 45 | } 46 | 47 | @Override 48 | public void gyncServices() { 49 | System.out.println("FH -- gyncServices"); 50 | } 51 | 52 | //WHO 53 | @Override 54 | public void covidTest() { 55 | System.out.println("FH - covid test"); 56 | } 57 | 58 | //non-overridden methods: 59 | public void optServices() { 60 | System.out.println("FH -- OPT Services"); 61 | } 62 | 63 | public void neuroServices() { 64 | System.out.println("FH -- neuroServices"); 65 | 66 | } 67 | 68 | //UN 69 | @Override 70 | public void pandemicControl() { 71 | 72 | } 73 | 74 | @Override 75 | public void bloodBank() { 76 | 77 | } 78 | 79 | 80 | 81 | } 82 | -------------------------------------------------------------------------------- /src/OOP_Interface/IndianMedical.java: -------------------------------------------------------------------------------- 1 | package OOP_Interface; 2 | 3 | public interface IndianMedical { 4 | 5 | public void oncologyServices(); 6 | 7 | public void gyncServices(); 8 | 9 | public void emergencyServices(); 10 | 11 | 12 | } 13 | -------------------------------------------------------------------------------- /src/OOP_Interface/TestHospital.java: -------------------------------------------------------------------------------- 1 | package OOP_Interface; 2 | 3 | public class TestHospital { 4 | 5 | public static void main(String[] args) { 6 | 7 | 8 | FortisHospital fh = new FortisHospital(); 9 | fh.audiologyServices(); 10 | fh.emergencyServices(); 11 | fh.ENTServices(); 12 | fh.gyncServices(); 13 | fh.physioServices(); 14 | fh.pathalogy(); 15 | USMedical.minFee(); 16 | System.out.println(USMedical.admission_fee);//50 17 | //USMedical.admission_fee = 100; 18 | 19 | //Top Casting: 20 | USMedical us = new FortisHospital();//child class object can be referred by parent interface ref variable. 21 | us.audiologyServices(); 22 | us.emergencyServices(); 23 | us.physioServices(); 24 | us.orthoServices(); 25 | 26 | //Down Casting -- not allowed at compile time 27 | //FortisHospital fh1 = (FortisHospital) new USMedical(); 28 | 29 | 30 | 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /src/OOP_Interface/UKMedical.java: -------------------------------------------------------------------------------- 1 | package OOP_Interface; 2 | 3 | public interface UKMedical { 4 | 5 | public void ENTServices(); 6 | 7 | public void pediaServices(); 8 | 9 | public void emergencyServices(); 10 | 11 | 12 | } 13 | -------------------------------------------------------------------------------- /src/OOP_Interface/UN.java: -------------------------------------------------------------------------------- 1 | package OOP_Interface; 2 | 3 | public interface UN { 4 | 5 | public void pandemicControl(); 6 | 7 | 8 | 9 | } 10 | -------------------------------------------------------------------------------- /src/OOP_Interface/UNHG.java: -------------------------------------------------------------------------------- 1 | package OOP_Interface; 2 | 3 | public interface UNHG { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /src/OOP_Interface/USMedical.java: -------------------------------------------------------------------------------- 1 | package OOP_Interface; 2 | 3 | public interface USMedical extends WHO{ 4 | 5 | int admission_fee = 50; 6 | 7 | // No method body 8 | // only method declaration -- method prototype 9 | // can not create the Object of Interface 10 | //interface vars are static and final by default 11 | 12 | public void orthoServices();//abstract method 13 | 14 | public void physioServices(); 15 | 16 | public void emergencyServices(); 17 | 18 | public void audiologyServices(); 19 | 20 | 21 | //After JDK 1.8: 22 | //1. we can have static methods with method body: 23 | public static void minFee() { 24 | System.out.println("min fee is 10 USD"); 25 | } 26 | 27 | //2. we can have default method with body: 28 | default void bloodBank() { 29 | System.out.println("US Medical- blood bank"); 30 | } 31 | 32 | 33 | } 34 | -------------------------------------------------------------------------------- /src/OOP_Interface/WHO.java: -------------------------------------------------------------------------------- 1 | package OOP_Interface; 2 | 3 | public interface WHO extends UNHG, UN{ 4 | 5 | public void covidTest(); 6 | 7 | 8 | 9 | } 10 | -------------------------------------------------------------------------------- /src/OOP_Interface_WebDriverExample/AmazonTest.java: -------------------------------------------------------------------------------- 1 | package OOP_Interface_WebDriverExample; 2 | 3 | public class AmazonTest { 4 | 5 | public static void main(String[] args) { 6 | 7 | WebDriver driver = null; 8 | 9 | //cross browser testing using top casting 10 | String browser = "chrome"; 11 | 12 | if (browser.equals("chrome")) { 13 | driver = new ChromeDriver(); 14 | } else if (browser.equals("firefox")) { 15 | driver = new FirefoxDriver(); 16 | } else if (browser.equals("safari")) { 17 | driver = new SafariDriver(); 18 | } else { 19 | System.out.println("Please pass the correct browser name...." + browser); 20 | } 21 | 22 | driver.get("http://www.amazon.com"); 23 | 24 | String title = driver.getTitle(); 25 | System.out.println(title); 26 | 27 | driver.findElement("username"); 28 | driver.sendKeys("admin@gmail.com"); 29 | 30 | driver.findElement("password"); 31 | driver.sendKeys("admin@123"); 32 | 33 | driver.findElement("login button"); 34 | driver.click(); 35 | 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /src/OOP_Interface_WebDriverExample/ChromeDriver.java: -------------------------------------------------------------------------------- 1 | package OOP_Interface_WebDriverExample; 2 | 3 | public class ChromeDriver implements WebDriver { 4 | 5 | public ChromeDriver() { 6 | System.out.println("Launch Google Chrome..."); 7 | } 8 | 9 | @Override 10 | public void findElement(String locator) { 11 | System.out.println("find the element using : " + locator); 12 | } 13 | 14 | @Override 15 | public void get(String url) { 16 | System.out.println("launch url with : " + url); 17 | } 18 | 19 | @Override 20 | public String getTitle() { 21 | 22 | return "title of the page"; 23 | } 24 | 25 | @Override 26 | public void click() { 27 | System.out.println("click on the element"); 28 | } 29 | 30 | @Override 31 | public void sendKeys(String value) { 32 | System.out.println("send the value : " + value); 33 | } 34 | 35 | @Override 36 | public void quit() { 37 | System.out.println("quit browser"); 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/OOP_Interface_WebDriverExample/FirefoxDriver.java: -------------------------------------------------------------------------------- 1 | package OOP_Interface_WebDriverExample; 2 | 3 | public class FirefoxDriver implements WebDriver{ 4 | 5 | 6 | public FirefoxDriver() { 7 | System.out.println("Launch Firefox..."); 8 | } 9 | 10 | 11 | @Override 12 | public void findElement(String locator) { 13 | System.out.println("find the element using : " + locator); 14 | } 15 | 16 | @Override 17 | public void get(String url) { 18 | System.out.println("launch url with : " + url); 19 | } 20 | 21 | @Override 22 | public String getTitle() { 23 | 24 | return "title of the page"; 25 | } 26 | 27 | @Override 28 | public void click() { 29 | System.out.println("click on the element"); 30 | } 31 | 32 | @Override 33 | public void sendKeys(String value) { 34 | System.out.println("send the value : " + value); 35 | } 36 | 37 | @Override 38 | public void quit() { 39 | System.out.println("quit browser"); 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/OOP_Interface_WebDriverExample/SafariDriver.java: -------------------------------------------------------------------------------- 1 | package OOP_Interface_WebDriverExample; 2 | 3 | public class SafariDriver implements WebDriver{ 4 | 5 | public SafariDriver(){ 6 | System.out.println("Launch Safari...."); 7 | } 8 | 9 | @Override 10 | public void findElement(String locator) { 11 | System.out.println("find the element using : " + locator); 12 | } 13 | 14 | @Override 15 | public void get(String url) { 16 | System.out.println("launch url with : " + url); 17 | } 18 | 19 | @Override 20 | public String getTitle() { 21 | 22 | return "title of the page"; 23 | } 24 | 25 | @Override 26 | public void click() { 27 | System.out.println("click on the element"); 28 | } 29 | 30 | @Override 31 | public void sendKeys(String value) { 32 | System.out.println("send the value : " + value); 33 | } 34 | 35 | @Override 36 | public void quit() { 37 | System.out.println("quit browser"); 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/OOP_Interface_WebDriverExample/SearchContext.java: -------------------------------------------------------------------------------- 1 | package OOP_Interface_WebDriverExample; 2 | 3 | public interface SearchContext { 4 | 5 | 6 | public void findElement(String locator); 7 | 8 | 9 | 10 | 11 | 12 | } 13 | -------------------------------------------------------------------------------- /src/OOP_Interface_WebDriverExample/WebDriver.java: -------------------------------------------------------------------------------- 1 | package OOP_Interface_WebDriverExample; 2 | 3 | public interface WebDriver extends SearchContext{ 4 | 5 | 6 | public void get(String url); 7 | 8 | public String getTitle(); 9 | 10 | public void click(); 11 | 12 | public void sendKeys(String value); 13 | 14 | public void quit(); 15 | 16 | 17 | 18 | 19 | } 20 | -------------------------------------------------------------------------------- /src/ThisKeyword/EComm.java: -------------------------------------------------------------------------------- 1 | package ThisKeyword; 2 | 3 | public class EComm { 4 | 5 | //Builder Pattern using this keyword 6 | 7 | public EComm login(String un, String pwd) { 8 | System.out.println("login with :" + un + " :" +pwd); 9 | return this; 10 | } 11 | 12 | public EComm search(String productName) { 13 | System.out.println("search with : " + productName); 14 | return this; 15 | } 16 | 17 | public EComm search(String productName, int price) { 18 | System.out.println("search with : " + productName + " price: " + price); 19 | return this; 20 | } 21 | 22 | public EComm addToCart(String productName) { 23 | System.out.println("Adding to cart: " + productName); 24 | return this; 25 | } 26 | 27 | public EComm checkout(String productName) { 28 | System.out.println("checkout this product: " + productName); 29 | return this; 30 | } 31 | 32 | public EComm doPayment(String CC, String pwd) { 33 | System.out.println("payment is done using : " + CC + " pwd " + pwd); 34 | return this; 35 | } 36 | 37 | public EComm generateOrder(String productName) { 38 | System.out.println("Your order id is : " + 12345 + " for this product " + productName); 39 | return this; 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/ThisKeyword/Shopping.java: -------------------------------------------------------------------------------- 1 | package ThisKeyword; 2 | 3 | public class Shopping { 4 | 5 | public static void main(String[] args) { 6 | 7 | EComm e1 = new EComm(); 8 | 9 | e1 10 | .login("naveen@gmail.com", "naveen@123") 11 | .search("Apple MackBook", 2000) 12 | .addToCart("Apple MacBook") 13 | .checkout("Apple MacBook") 14 | .doPayment("1234 1222 4444 3333", "Testing@1234") 15 | .generateOrder("Apple MacBook"); 16 | 17 | System.out.println("-----------"); 18 | 19 | e1 20 | .login("naveen@gmail.com", "naveen@123") 21 | .addToCart("Nike shoes") 22 | .doPayment("1234 1222 4444 3333", "Testing@1234") 23 | .generateOrder("Nike shoes"); 24 | 25 | 26 | System.out.println("-----------"); 27 | 28 | 29 | e1 30 | .addToCart("Nike shoes") 31 | .doPayment("1234 1222 4444 3333", "Testing@1234") 32 | .generateOrder("Nike shoes"); 33 | 34 | 35 | 36 | } 37 | 38 | } 39 | --------------------------------------------------------------------------------