java7PMVh-1

You might also like

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 34

IT ---> Dev and Tester

Developer ---> develop the application


Tester ---> Test the application

Tester ---> Expected result met the actual result

Expected Result ---> client


Actual Result ---> Developers

Testing ---> Manual and Automation

Manual ---> human effort --> dont need any coding knowledge --> no tools required
-->MSEXCEL(update the status)

Automation ---> We need a tool called "Selenium"

Similar Automation Tools:

* Selenium
* Selenese
* Protractor ---> update has been stopped
* cypress ---> grooming slowly
* katalon

Applications:

* Web application
* desktop application
* Mobile Application

* Web application:

* anything which we are opening in the browser

eg: selenium

eg: Whatsapp web

* Desktop Application:

* apps which is in desktop

eg: AutoIT

eg: whatsapp application

* Mobile Application:

* apps in the mobile

eg: whatsapp

Appium
------------------------------------------------------------------------

Java:
* core java(15 hours)

Selenium:

Manual Testing
----------------------------------------------------------------------

Programming languages:
c
C++
Java ---> 2nd
JS
Ruby
Python ---> 1st
C#
.Net

Java --->

1991 ---> James Gosling ---> sun microsystems ---> Oak tree ---> OAK language

1995 --> License issue ---> oak name has been revert back ---> java (paid language)

2001 ---> Oracle aquired the java(free of cost)

Features:

* java is the open source(anyone can contribute)


* java is free of cost
* java is platform independent(different machines)
* java is strictly typed lanaguage
int a = 10;
char c = 'x';
* java is easily portable
write once and access anywhere

Installation:

jdk ---> 1.8 version


latest version --> 1.18

Goto: https://www.oracle.com/java/technologies/downloads/#java8-windows

Rigth click on this pc ---> check your system type--> 64 bit

32 ---> 86 installer

create oracle account and sign in to download

Once downloaded and installed goto command prompt and enter "java -version"

set the path:

Two ways:

1) set path="C:\Program Files\Java\jdk1.8.0_333\bin"


2) Environment variables --> system variabled add new --> JAVA_HOME and var value =
"C:\Program Files\Java\jdk1.8.0_333" then click on "path" --> edit ---> %JAVA_HOME
%/bin

CMD prompt --> javac --> to verify the path has benn succesfully set

Editor:

* Eclipse
* IntelliJ
* VisualStudio
* RAD(IBM)
* Pycharm(for python)

* Eclipse:

https://www.eclipse.org/downloads/

Select Eclipse for java developers and install the eclipse


--------------------------------------------------------------------

Variables:

* container to store the values

syntax:

datatype varName = varValue;

int a = 10; //-214C to 214C

int b = 20;

datatype:

1) Primitive data type---> ranged


2) Non Primitive data type --> there's no range

------------------------------------

Notations:

* Pascal Notation
* Camel Notation

* Pascal Notation:

* First letter of each word should start with the Uppercase


* No special characters allowed
* Only the underscore(_)

special chars: !@#$%^&*()(*&

eg:

ChennaiSuperKings
LoginPage
Login_Page

* Camel Notation:
* first letter of first word should be in Lowercase and first letter of everyother
word should be in uppercase
* no special characters allowed
* only underscore(_) is allowed

Method name, package name

eg: chennai_Super_Kings
chennai_Super
chennai
loginPage
-------------------------------------------------------------------

Project
|
package
|
Class
|
Method

* Class
Initialize the variable
Method
Main Method
object creation
using object we need to call the method

print:
system.out.println("");

package demoSession;

public class FirstJavaCode {

int var1 = 10;


int var2 = 20;

public void addNumbers() {

System.out.println(var1 + var2);

// type main and ctrl + space and click enter


public static void main(String[] args) {

// To create an object --> className obj = new ClassName();

FirstJavaCode add = new FirstJavaCode();

// call the method using the object


add.addNumbers();

}
}

----------------------------------------------
Operators:

* ArithmeticOperators
* Relational Operators
* Logical Operators
* Assignment Operators
* Conditional Operators
* shorthand operators
* Increment/decrement operators

* ArithmeticOperators:

+ ---> Addition
- ---> Subtraction
* ---> Multlipication
/ ---> division
% ---> Modulo ---> remainder value

* Realtional Operators:

it will return either true or false

* >=
* <=
* ==
* <
* >
* !=

package operatorsDemo;

public class RelaDemo {

int var1 = 10;

int var2 = 5;

public void compareNumbers() {

System.out.println(var1 > var2); // true

System.out.println(var1 < var2); // false

System.out.println(var1 <= var2); // false

System.out.println(var1 >= var2); // true

System.out.println(var1 == var2); // false

System.out.println(var1 != var2); // true

public static void main(String[] args) {


RelaDemo demo = new RelaDemo();
demo.compareNumbers();

3) Logical Operators:

* it will also return true or false

&& ---> AND operators ---> both the condition should satisfy
|| ----> OR Operators ---> either one condition should satisfy
! ---> NOt operators

package operatorsDemo;

public class LogicalDemo {

int var1 = 10;


int var2 = 5;

public void compareNumbers() {

System.out.println((var1>var2)&&(var1<var2)); //false

System.out.println((var1>=var2)&&(var1!=var2)); // true

System.out.println((var1<var2)||(var1>var2)); // true

System.out.println((var1!=var2)||(var1<=var2)); // true
}

public static void main(String[] args) {

LogicalDemo demo = new LogicalDemo();

demo.compareNumbers();

4) Assignment Operators:

= ---> assigning one value to the variable

int a = 5;

5) Shorthand operators:

+=
-=
*=
/=
%=
var1 = var1 + var2

var1+=var2
var1 = var1 * var2

var1*=var2

package operatorsDemo;

public class ShortHand {

int var1 = 10;


int var2 = 3;

public void shortDemo() {

// var1 = var1 + var2;

// var1+=var2;

System.out.println(var1 += var2);
System.out.println(var1 -= var2);
System.out.println(var1 *= var2);
System.out.println(var1 /= var2);
System.out.println(var1 %= var2);

public static void main(String[] args) {

ShortHand demo = new ShortHand();

demo.shortDemo();

6) Inc/dec Operator:
+1 will be added -->increment
-1 will be added ---> decrement
var++ ---> post increment
var-- ----> post decrement
--var ----> pre decrement
++var ----> pre increment

package operatorsDemo;

public class indecDemo {

int var1 = 10;

public void incdecDemo() {

System.out.println(var1); //10

System.out.println(var1++); //10
System.out.println(var1); // 11

System.out.println(var1--); //11

System.out.println(var1); //10

System.out.println(++var1); //11

System.out.println(--var1); // 10

System.out.println(var1); // 10
}

public static void main(String[] args) {


indecDemo demo = new indecDemo();

demo.incdecDemo();
}

7) Conditional Operator:

Syntax:

(condition)?statement1:statement2

package operatorsDemo;

public class ConditionOper {

int age = 18;

public void ageCheck() {

System.out.println((age>=18)?"Eligible to vote":"Not Eligible to


vote");
}

public static void main(String[] args) {

ConditionOper ope = new ConditionOper();

ope.ageCheck();

--------------------------------------------------------------------------

* Control Statements:

* Controlling the flow of the execution by giving some condtions

if
if else
nested if
if else if ....

* Jump statments
break
continue
return

* if:

if(condition){

statements;

package controlState;

public class PracticeSession {

int age = 18;

public void ageCheck() {

if (age >= 18) {

System.out.println("eligible to vote");
}

if (age <= 18) {

System.out.println("not eligible to vote");

if (age == 18)

System.out.println("Need to apply voter id");

public static void main(String[] args) {

PracticeSession op = new PracticeSession();

op.ageCheck();

2) if

else

package controlState;

public class PracticeSession {

int age = 18;


public void ageCheck() {

if (age >= 18) {

System.out.println("eligible to vote");
}

else {

System.out.println("Not eligible to vote");


}

public static void main(String[] args) {

PracticeSession op = new PracticeSession();

op.ageCheck();

3) Nested if:

if(condition){

if(condiiton){

if(condition){

package controlState;

public class PracticeSession {

int num = 36;

public void ageCheck() {

if (num % 2 == 0) {

System.out.println(num + " is divisble by 2");

if (num % 4 == 0) {

System.out.println(num + " is divisible by 4");

if (num % 6 == 0) {

System.out.println(num + " is divisible by 6");


}
}
}
}

public static void main(String[] args) {

PracticeSession op = new PracticeSession();

op.ageCheck();

4) if else if ladder

if(condtion)
{
statements;
}

else if(condition){
statements;
}

else{

statements;

marks = 20

81 - 100 ---> grade A


61 - 80 ---> grade B
41 - 60 ---> grade c
21- 40 --> grade d
0- 20 ---> failed

package controlState;

public class PracticeSession {

int marks = 3;

public void gradeCheck() {

if ((marks > 81) && (marks <= 100)) {

System.out.println("Grade A");
}

else if ((marks > 61) && (marks <= 80)) {

System.out.println("Grade B");
}

else if ((marks > 41) && (marks <= 60)) {

System.out.println("Grade C");
}

else if ((marks > 21) && (marks <= 40)) {

System.out.println("Grade D");
}

else {

System.out.println("failed");
}

public static void main(String[] args) {

PracticeSession op = new PracticeSession();

op.gradeCheck();

5) Switch Statements:

Switch(condition)

case value:
statements;
break;
package controlState;

public class SwitchDemo {

String proof = "Aadhar";

public void voteCheck() {

switch (proof) {
case "Pan":

System.out.println(proof + " is not valid to vote");

break;
case "License":
System.out.println(proof + " is not valid to vote");
break;
case "RationCard":
System.out.println(proof + " is not valid to vote");
break;

case "Aadhar":
System.out.println(proof + " is not the valid proof");
break;
default:
System.out.println("he is not elgible to vote");
break;
}
}

public static void main(String[] args) {


SwitchDemo demo = new SwitchDemo();
demo.voteCheck();

}
-----------------------------------------------------------------------------
OOPS:

Object Oriented Programming Lanaguage

99% ---> oops

* Class
* Object
* Inheritance
* Polymorphism
* Encapsulation
* Abstraction
* Interface

* Inheritance:

* process of acquring the properties of the parent class to the child class

Keyword: "extends"

parent class ---> base class ---> super class


child class --> sub class ---> derived class

* Single Inheritance ---> one parent --> one child


* Multilevel Inheritance ---> one parent ---> one child --> form that child to
another child
* Multiple Inheritance ---> more than one parent for one child ---> java doesnot
support multiple inheritance, with the help of interface we can acheive
* Hierarchical Inheritance ----> one parent ---> multiple child
* Hybrid Inheritance ---> all combinations

Advantages:

* code reusability

* Single Inheritance ---> one parent --> one child

package InheritanceDemo;

public class FatherHouse {

public void activaBike() {

System.out.println("this is my fathers bike");


}
public void Cycle() {

System.out.println("This is my father's cycle");


}

package InheritanceDemo;

public class SonHouse extends FatherHouse {

public void ktmBike() {

System.out.println("this is son's ktm bike");


}

public void pulsarBike() {

System.out.println("this is son's pulsar bike");


}

public static void main(String[] args) {

SonHouse son = new SonHouse();

son.ktmBike();
son.pulsarBike();
son.activaBike();
son.Cycle();
}

}
------------------------------------------------------

2) Multilvel inheritance --->one parent ---> one child --> form that child to
another child

grandparent ---> parent ---> child

package InheritanceDemo;

public class GrandParent {

public void Cycle() {

System.out.println("this is my grandparent cycle");


}

public void scooter() {

System.out.println("this is my grandparent scooter");


}

package InheritanceDemo;

public class FatherHouse extends GrandParent{


public void activaBike() {

System.out.println("this is my fathers bike");


}

public void heroHonda() {

System.out.println("This is my father's cycle");


}

package InheritanceDemo;

public class SonHouse extends FatherHouse {

public void ktmBike() {

System.out.println("this is son's ktm bike");


}

public void pulsarBike() {

System.out.println("this is son's pulsar bike");


}

public static void main(String[] args) {

SonHouse son = new SonHouse();

son.ktmBike();
son.pulsarBike();
son.activaBike();
son.Cycle();
son.scooter();
son.heroHonda();
}

--------------------------------------------------------------------
3) Hierarchical inheritance:

package InheritanceDemo;

public class FatherHouse{

public void activaBike() {

System.out.println("this is my fathers bike");


}

public void heroHonda() {

System.out.println("This is my father's cycle");


}

}
package InheritanceDemo;

public class SonHouse extends FatherHouse {

public void ktmBike() {

System.out.println("this is son's ktm bike");


}

public void pulsarBike() {

System.out.println("this is son's pulsar bike");


}

public static void main(String[] args) {

SonHouse son = new SonHouse();


DaughterHouse daughter = new DaughterHouse();

son.ktmBike();
son.pulsarBike();
son.activaBike();
son.heroHonda();
daughter.scooty();
daughter.vespaBike();

package InheritanceDemo;

public class DaughterHouse extends FatherHouse {

public void scooty() {

System.out.println("this is my daughter's scooty");


}

public void vespaBike() {

System.out.println("this is my daughter's vespa bike");


}

}
---------------------------------------------------------------------------

Polymorphism:

* poly means many


* morphism ---> different types

performing the action in different ways

* Method overloading ---> compile time polymorphism


* Method overriding----> run time polymorphism
* different class , same method, same parameters
---
* Method overloading ---> compile time polymorphism
* same class name, same method name, but different parameters/arguments

* add the datatypes


* chnage the order of the data type
* increase the datatype

package PolymorDemoi;

public class MethodOverDemo {

public void addNumbers() {

System.out.println("addition is " + (20 + 30));


}

public void addNumbers(int a, int b) {

System.out.println(a + b);

public void addNumbers(int a, double b) {

System.out.println(a + b);

public void addNumbers(double b, int a) {


System.out.println(a + b);
}

public void addNumbers(int a, double b, int c) {

System.out.println(a + b + c);

public static void main(String[] args) {

MethodOverDemo demo = new MethodOverDemo();


demo.addNumbers();
demo.addNumbers(10, 10);
demo.addNumbers(20, 10.0);
demo.addNumbers(20.0, 30);
demo.addNumbers(40, 10.0, 50);
}

---------------------------------

* Method Overiding or run time polymorphism:

* different class , same method, same parameters

package PolymorDemoi;
public class MaryAmmanBank {

public void CurrentAccount() {

System.out.println(" 10% interest");


}

public void SavingsAccount() {

System.out.println(" 6% Interest");
}

package PolymorDemoi;

public class MuruganBank extends MaryAmmanBank{

@Override
public void CurrentAccount() {

System.out.println(" 12% interest");


}

public void SavingsAccount() {

System.out.println(" 6% interest");
}

public static void main(String[] args) {

MuruganBank bank = new MuruganBank();


bank.CurrentAccount();
bank.SavingsAccount();

MaryAmmanBank bank1 = new MaryAmmanBank();


bank1.CurrentAccount();
bank1.SavingsAccount();
}

}
-------------------------------------------------------
Encapsulation:

* binding/wrapping/capsulating the data and the method together into the single
unit

* for securing our code

How to achieve the encapsulation:

* we can use of private access modifier


* we need to generate the getter and setter method

source--->generate getters and setters

package encapDemo;

public class BankDataBase {


private String password = "icici123@$$";

public String getPassword() {


return password;
}

public void setPassword(String password) {


this.password = password;
}

package encapDemo;

public class HackerClass {

public static void main(String[] args) {

BankDataBase data = new BankDataBase();

System.out.println(data.getPassword());

data.setPassword("Hacker123");

System.out.println(data.getPassword());

}
----------------------------------------------------------------------
Constructor:

* it is used to intialize the object


* whenever the object is created, the constructor is automatically invoked
* constructor name should be same as class name
* doesnot have any return type

ClassName name = new ClassName();

package construcDemo;

public class CalcDemo {

int var1;
int var2;

// non paramterized constructor


CalcDemo() {
var1 = 20;
var2 = 30;
System.out.println("Addition value is : " + (var1 + var2));

}
CalcDemo(int a, int b) {

System.out.println("Addition of a+b " + (a + b));

// constructor overloading
CalcDemo(int a, double b) {

System.out.println("inta and double b " + (a + b));

CalcDemo(int a, double b, int c) {

System.out.println("inta and double b and int c " + (a + b + c));

public static void main(String[] args) {

CalcDemo demo = new CalcDemo();


CalcDemo demo1 = new CalcDemo(40, 50);
CalcDemo demo2 = new CalcDemo(10, 40.0);
CalcDemo demo3 = new CalcDemo(20, 50.0, 10);

}
}
------------------------------------------------------------
this():

* it is used to call the current class constructor/method


* it should be the first line inside the constructor

package construcDemo;

public class CalcDemo {

int var1;
int var2;

// non paramterized constructor


CalcDemo() {
this(20, 50);
var1 = 20;
var2 = 30;
System.out.println("Addition value is : " + (var1 + var2));

CalcDemo(int a, int b) {
this(10, 20.0);
System.out.println("Addition of a+b " + (a + b));

// constructor overloading
CalcDemo(int a, double b) {
this(10, 30.0, 40);
System.out.println("inta and double b " + (a + b));

CalcDemo(int a, double b, int c) {

System.out.println("inta and double b and int c " + (a + b + c));

public static void main(String[] args) {

CalcDemo demo = new CalcDemo();


CalcDemo demo1 = new CalcDemo(40, 50);
CalcDemo demo2 = new CalcDemo(10, 40.0);
CalcDemo demo3 = new CalcDemo(20, 50.0, 10);

}
}
------------------------------------------

* super:

* it is used to call the parent class constructor

package construcDemo;

public class HomePage {

HomePage() {

System.out.println("this is my home page");


}

package construcDemo;

public class LoginPage extends HomePage{

LoginPage(){
super();
System.out.println("this is my login page");
}

public static void main(String[] args) {

LoginPage page = new LoginPage();

----------------------------------------------------------------
Constructor chaining:
* using the one object calling multiple constructors

package construcDemo;

public class CalcDemo {

int var1;
int var2;

// non paramterized constructor


CalcDemo() {
this(20, 40);
var1 = 20;
var2 = 30;
System.out.println("Addition value is : " + (var1 + var2));

CalcDemo(int a, int b) {
this(20, 50.0);
System.out.println("Addition of a+b " + (a + b));

// constructor overloading
CalcDemo(int a, double b) {
this(20, 40.0, 60);
System.out.println("inta and double b " + (a + b));

CalcDemo(int a, double b, int c) {

System.out.println("inta and double b and int c " + (a + b + c));

public static void main(String[] args) {

CalcDemo demo = new CalcDemo();

}
}

------------------------------------------------
this and super keyword should not be used at the same place

package construcDemo;

public class LoginPage extends HomePage {

LoginPage() {
//super(); keyword is hidden here
this("ramesh");
System.out.println("this is my login page");
}
LoginPage(String username) {
System.out.println(username);
}

public static void main(String[] args) {

LoginPage page = new LoginPage();

}
------------------------------------------------------------
Access modifier:

* public
* private
* Protected
* default

public:

* within the class


* within the package
* outside the package by subclass
* outside the package

package accessModDemo;

public class LoginPage {

public void msg() {

System.out.println("hello i am in facebook login page");


}

package accessModDemo;

public class HomePage {

public static void main(String[] args) {

LoginPage page = new LoginPage();


page.msg();
}

2) Private:

* access only within the class

package accessModDemo;

public class PaymentPage {


private int amount = 2000;

private void msg() {

System.out.println("My order amount is " + amount);


}

3) Default:

* within the class


* within the package

package accessModDemo;

class A {

void msg() {

System.out.println("this is the default access modifier");


}

package accessModDemo;

public class B {

public static void main(String[] args) {

A a = new A();

a.msg();

4) Protected:

* within the class


* within the package
* outside the package with the subclass
* will not support outside the package

package accessModDemo;

public class A {

protected void msg() {

System.out.println("this is the default access modifier");


}

package construcDemo;
import accessModDemo.*;
public class B extends A {

public static void main(String[] args) {

B b = new B();
b.msg();

}
-----------------------------------------------------------------------

String:

* it is the collection of characters

char c = 's';

String s = "sdfghgerfdsd";

String str = "my name is ramesh";

String is mutable or immutable?

mutable ---> any modifications can be done once it has been declared
immutable --> modifications cannot be done

Why string is immutable?

String is immutable ---> once it has been declared we cannot modify or do any
changes to the string

Can we make the string as mutable?

* yes we can make the string as mutable but with the help of StringBuffer and
StringBuilder

You might also like