Wednesday 28 June 2017

Strings in Java

Strings in Java
===========================================================
String represents group of characters.

In C, C++ languages, a string represents an array of characters, where the last character being '\0' represents the end of the string. But this is not valid

in Java, a string is an object of String class.  It is not a character array.  In java, we got character array also, but strings are given a different treatment

because of their extensive use on internet.  JavaSoft people have created a class separately with the name 'String' in java.lang(language) package with

all necessary methods to work with strings.

Even though, String is a class, it is used often in the form of a data type
eg: String s="java";

Is String is class or datatype?

String is a class in java.lang package.   But in java, all classes are also considered as data types.  So we can take String as a data type also.

Can we call a class as datatype?

Yes, a class is also called 'user-defined' data type.  This is because a user can create a class.

Creating Strings:
-----------------------
1.String S;
S="Hello";

2.String S="Hello";

3.String S=new String("Hello");

Character Array( to String object):
--------------------------------------------
char arr[]={'A','P','T','E','C','H'};

String S=new String(arr);

String S=new String(arr,2,4);


Example:I
----------------

//Using charAt()
//It returns character at given index
class A56
{
public static void main(String args[])
{
//charAt()
String empname=new String();
empname = "aptech computers";
System.out.println(empname.charAt(10));
}
}

//output is---   p

---------------------------------------------------------------------------------
Example II
-------------------------
//Using concat()
//It is used to concatinate  two given strings

class A57
{
public static void main(String args[])
{
String empname=new String();
empname = "Aptech";
System.out.println(empname.concat(" Grafx"));


}
}

--------------------------------------------------------------------------------
Example III
-------------------------------
//Using compareTo()
//It returns the difference between two given strins based on ASCII values

class A58
{
public static void main(String args[])
{

String empname=new String();
empname = "Aptech";

System.out.println(empname.compareTo("aptech"));


}
}

--------------------------------------------------------------------------------
Example IV
------------------------------------
class StrDemo1
{
public static void main(String a[])
{
String S1=new String("Hello");
String S2=new String("hello");

//compareTo()
int S=S1.compareTo(S2);
if(S==0)
{
System.out.println("Both are Same..Difference is: "+S);
}
else
{
System.out.println("Both not are Same..The difference is: "+S);
}


//compareToIgnoreCase()
int SS=S1.compareToIgnoreCase(S2);
System.out.println("The Result of compareToIgnoreCase() is Both are Same: "+SS);

//indexOf()

int x=S1.indexOf('l');
System.out.println("Index position of 'l' is: "+x);



}
}
---------------------------------------------------------------------------
Example V
-----------------------------------

class StrDemo3
{
public static void main(String a[])
{
String S1=new String("Hello");
String S2=new String("   Hello World    ");
System.out.println(S1.replace('H','Y'));
System.out.print(S2);
System.out.println(S1);
System.out.print(S2.trim());
System.out.println(S1);

}

}

---------------------------------------------------------------------------------
Example VI
-------------------------------------------

//Copying String to Character Array using getChars() method


class Strcpy
{
public static void main(String a[])
{
String str="Aptech Computer Education";
char arr[]=new char[20];

// copy from string to arr
str.getChars(7,15,arr,0);

System.out.println(arr);
}
}

//output is --   computer

---------------------------------------------------------------------------------
Example VII
-------------------------------------------
//using equals() method and == operator

class StrCmp
{
public static void main(String a[])
{
String s1="Hello";
//String s2="Hello";

String s2=new String("Hello");

//if(s1==s2)
if(s1.equals(s2))
{
System.out.println("Both are Same");
}
else
{
System.out.println("Not Same");
}


}
}


/* object reference:
-------------------------
Object reference is a unique hexadecimal number representing the memory adress of the object.  It is useful to access the members of the object.

Difference between == and equals():
------------------------------------------------
== operator compares the references of the string objects.  It does not compare the contents of the objects.  equals() method compares the contents.

While comparing the strings, equals() method should be used as it yields the correct result.

String constant pool:
----------------------------
String constant pool is a separate block of memory where the string objects are held by JVM.  If string object is created directly, using assignment

operator as: String s1="Hello", then is is stored in string constant pool.



*/

---------------------------------------------------------------------------------
Example VIII
-------------------------------------------
//Using split()
//It Converts the string into pieces

class Strsplit
{
public static void main(String a[])
{
String str="Aptech Computer Education";
String s[];
s=str.split(" ");

for(int i=0; i<s.length; i++)
System.out.println(s[i]);
}
}

Output
-------------
Aptech
Computer
Education

---------------------------------------------------------------------------------
Example IX
-------------------------------------------
/*
Objects are divided into mutable and immutable.
Mutable Objects are those objects whose contents can be modified.

Immutable Objects are those objects, once created  can not be modified.

String class objects are immutable.*/

class StrImmut
{
public static void main(String a[])
{
String S1="Data";
String S2="Base";

S1=S1+S2;
System.out.println(S1);
}
}

---------------------------------------------------------------------------------
Example X
-------------------------------------------

/*
Differences between String and StringBuffer Class
------------------------------------------------------------------
String class objects are immutable, their contents cannot be modified.  StringBuffer class objects are mutable, so they can modified.
*/
class StrBuff
{
public static void main(String a[])
{
StringBuffer sb=new StringBuffer("Data");
System.out.println(sb);

//append()
System.out.println(sb.append("Base"));

//indexOf()
int m=sb.indexOf("a");
System.out.println("The index position of 'a' is "+m);

//lastIndexOf()
int n=sb.lastIndexOf("a");
System.out.println("The last index position of 'a' is "+n);

//length()
System.out.println("The Length is " + sb.length());


//delete()
System.out.println("After Deleting: " + sb.delete(0,4));


//reverse()
System.out.println("The Reverse is " + sb.reverse());

//replace()
StringBuffer sb1=new StringBuffer("High Cost");
System.out.println(sb1.replace(0,4, "Low"));

//substring()
System.out.println("Substring of sb1 is: "+sb1.substring(4));

System.out.println("Substring of sb1 is: "+sb1.substring(0,3));
}
}

---------------------------------------------------------------------------------
Example XI
-------------------------------------------
//Palindrome or not

import java.io.*;

class StrBuff1
{
public static void main(String a[])throws IOException
{

BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

System.out.print("Enter a String: ");
String str=br.readLine();
String temp=str;
StringBuffer sb=new StringBuffer(str);
sb.reverse();
System.out.println(sb);
str=sb.toString();
if(temp.equalsIgnoreCase(str))
{
System.out.println(temp+" is Palindrome");
}
else
{
System.out.println(temp+" is not a Palindorme");
}
}
}

---------------------------------------------------------------------------------
Example XII
-------------------------------------------
import java.io.*;

class StrBuff
{
public static void main(String a[]) throws Exception
{
StringBuffer sb=new StringBuffer();

BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.print("Enter Surname: ");
String sur=br.readLine();
System.out.print("Enter middle name: ");
String mid=br.readLine();
System.out.print("Enter Last Name: ");
String last=br.readLine();

//append
sb.append(sur +" ");
sb.append(last+ " ");
System.out.println("Name: "+sb);

//insert
int n=sur.length();
sb.insert(n,mid+" ");

System.out.println("Full Name: "+sb);
System.out.println(" In reverse: "+sb.reverse());



}
}

Tuesday 13 June 2017

Object Oriented Programming

OBJECT ORIENTED PROGRAMMING SYSTEM
=================================================

OOPS:- Object Oriented Programming Language
---------------------------------------------------------------
It is very important  concept in Java  Language.  OOPS have three parts based on their process.

a.OOD:-Object Oriented Designing
b.OOA:-Object Oriented Approach
c.OOP:-Object Oriented Programming
The combination of above three parts are called "OOPS".

Above all process is used to develop any application systematically by following set of predefined standards.  All the standards comes under "Unified Modiling Language"(UML)

a.Object Oriented Designing(OOD):-
---------------------------------------------
It stands for object oriented design.  It determines to develop the application by phasewise designing of each module and each module will be designed later by following set of methods, principles and applications.

b.Object Oriented Approach(OOA):-
----------------------------------------------
It follows the object oriented designing based on its (OOD) phase.

c.Object Oriented Programming(OOP):-
--------------------------------------------------
It determines the real implementation of program(coding) by following set of functions libraries,header files and other technical tools by performing a suitable syntaxes.  Any real implementation of the program in OOP which follows a standard structure of program.

In Java we have a standard structure of program.  If you write program we should clear about object.

* Standard Structure of Program in OOPS:-

class
Object
objective
1.Data Members
2.Member Functions



Class:-
In a Java program the "class"  keyword denotes that the Java program follows this standard of class structure.
(or)
Class is nothing but collection of data and functions.
(or)
Collection of data members and member functions.



2.Objective:-
It is a invisible and it is the end result of an application which can be achieved using data members and member functions. Objective means end result of the programme.

3.Data Members:-
Data members are the elements which can be participated in a prog to achieve the objective of an application.

4.Member Function:-
It is a process of a technic in a program which can take a parameter and returns a value.  Member function can be called methods in OOPS Programming.

5.Object:-
It is a instance of a class which can be gives the reference to its.  The data member and the member functions which can be used outside of the class.
(or)
Object is nothing but instance of class.

Datatypes:-
Datatypes which are denotes what type of data that your processing to our program.

Variables:-
It is a location memory where we can store the values into the memory those values in the memory called "constants".

   OOPS:- Object Oriented Programming System
--------------------------------------------------------------
1.Encapsulation
2.Data Abstraction
3.Polymorphism
4.Inheritance

1.Data Encapsulation:-
The union of data and functions into objects is known as Data Encapsulation.
(or)

Details of what a class contains need not be visible to other classes and objects that use it.  Instead, only specific information can be made visible and the others can be hidden.  This is achieved through encapsulation, also called data hiding.  Both abstraction and encapsulation are complementary to each other.

Data Abstraction:-
-----------------------
We can give restricting the data, to set a number of functions.
(or)
It gives security.
(or)

Abstraction is the feature of extracting only the required information from objects.  For example, consider a television as an object.  It has a manual stating how to use the television.  However, this manual does not show all the technical details of television, thus giving only an abstraction to the user.

Polymorphism:-
-------------------
It is ability to take more than one form.
(or)
Use of something for different purposes.
(or)

Polymorphism is the ability to behave differently in different situations.  It is basically seen in programs where you have multiple method declared with the same name but with diferent parameters and different behavior.

Inheritance:-
----------------
Relation between two classes.
(or)
Object of one class can acquire the properties of  another class.
(or)

Inheritance is the process of creating a new class based on the attributes and methods of an existing class.  The existing class is called the base class whereas the new calss created is called the derived class.  This is very important concept of objet-oriented programming as it helps to reuse the inherited attributes and methods.

Super Class:-
---------------
It is a old class or parent class
Sub Class:-
--------------------
It is a new class or child class which can acquire the properties from base class.



Thursday 25 May 2017

Manual Testing Part - 1

S/w Testing:
It is a process used to identify correctness, completeness and quality of developed S/w application
Or
In simple S/w testing is a combination of Verification and Validation
Advantages of S/w Testing:
        -it will help to deliver  reliable product to the customer
        -it will reduce maintenance cost for a project
        -it will help to stay in Business
        -to deliver bug free application to the customer
Objective of TE:
        Objective of TE is to identify defects in application, when those are resolved then S/w quality improves

Defect:

It is a deviation between expected to actual results in AUT
Defect can also called as an Issue/Incident/fault

AUT: Calculator
Scenario: multiplication
Procedure:
        Click on “9”
        Click on “*”
        Click on “5”
        Click on “=”
        Expected value is “45”
        Actual result is “14”
        Status: failed
Why?
a*b
a+bàLogical errors

note:
in general defects may present in application due to human mistakes while writing the programs like logical errors and Syntax Errors
ex:
Required Scenario:  (Value1+Value2)*value3
Dev-1: (Value1*Value2)+Value3  àLogical error
Dev-2: (Value1+Value2*value3  àSyntax Error
Error –it is a terminology related to programs level
Bug:
When developers are accepted our defects which are reported then those are called Bugs
Failure:
When defects are reached to the end user then it is called failure
Quality S/w:
From producer point of view when application fulfilled with all the client requirements and end user point of view when application fit for use then it is consider as quality s/w
Following are the major factors depend on S/w quality:
i.                  Budget/Cost
ii.              In time Release
iii.           Reliability
a.    Meet client requirements in terms of functionalities
b.   Meet client expectations in terms of speed, compatibility, security, usability, recovery, maintainability …etc

Some of the major activities in S/w Company:
1.   Coding:
Writing the programs using programming/scripting languages in order to develop the application is called “coding”
It is performed by Developers
2.   **Testing:
Once application developed that will be delivered to separate testing team
Whereas TE’s will validate application as per client requirements and expectations
Testing team members are:
        -Test Manager (>7+yrs of Exp)
        -Test Lead (> 5+yrs of Exp)
        -Sr. TE (> 3+yrs of Exp)
        -TE/Trainee (0-2+yrs of Exp)
3.   **Defect Reporting:
Notifying about the defects to developers is called Defect Reporting
It is performed by TE’s

4.   Debugging:
Analyzing source code of the application in order to identify root cause for a defect
It is performed by Developers

5.   Bug fixing:
Modifying source code of the application in order to solve the defects is called Bug fixing/Bug Resolving
It is performed by Developers

Skill set required for Functionality TE:
-knowledge on Manual testing concepts
-knowledge on any one of the Functionality testing tool like Selenium/QTP
-knowledge on any one of the Defect Reporting tool like Quality Center/Bugzilla
-some knowledge on any DB technology like SQL server/Oracle
Software Testing Methods
In general organization follows two types of methods to validate applications. They are
1.   Manual Testing
2.   Automation Testing
1.   Manual Testing:
Without using any automation tool, Test Engineer (TE) directly interacts with application to verify actual behavior while performing operations is called Manual Testing.

For Manual Testing, TE will prepare test cases and those are used to validate application.
Ex: I want to check a file is going to upload in gmail or not.
2.   Automation Testing:
Any task or activity performed with help of tool/programs is called Automation.

Automating human activities (i.e. Test Execution) in order to validate application is called Automation Testing. Automation Testing can be performed using programs/scripting languages or using any one of the third party automation tools like Selenium/QTP/Win runner/Rational Robot/QA Run etc.

For automation testing we need to develop the automation test scripts.

Roles and Responsibilities of Test Engineer(3 + Years’ Experience of Manual and Automation Testing:

1.   Review on Requirement Documents like BRS and FRS in order to understand application functionalities.
2.   Identify Test Scenarios for allocated module.
Note: Scenario is nothing but a functionality.
Test Scenario: It describes test condition or requirement or functionality which we need to validate.
Ex: Identify Test Scenarios in gmail home page.

TS01: Login to gmail
TS02: Find my account
TS03: Create new account
TS04: Selection of language
3.   Prepare Test cases of Manual Testing.
Test case: It describes validation procedure of a specific requirement in application.
Ex: Identify possible test cases to validate login functionality.

TC01: Verify login functionality using valid data.
TC02: Verify login functionality using Invalid data.
TC03: Verify login functionality without data.

Ex: Write TC to verify login functionality using invalid data.
4.   Develop the automation test scripts
5.   Review on Test Cases and automation test scripts
6.   Execution of Test Cases and automation test scripts.
7.   Defect Reporting and Prioritize Defects.
8.   Performing Re-Testing and Regression Testing.

        Skill Set
1.   Knowledge of Manual Testing
2.   Knowledge on Selenium/QTP
3.   Defect Tracking Tool
Software Program
Set of Statements, logics and related data to perform specific task in a system.
Eg:
Int a=10;
Int b=20;
Int c=a+b;
System.out.println©;
Task: To perform Addition

10 & 20 are data.
Software:
Set of instructions or programs to perform related activities in a system.
Eg: Ms-Word, www.youtube.com etc.

Based on Development Software can be categorized into two types.

i.                  Product Based Software
ii.              Project Based Software
i.                  Product Based Software:
Whenever software developed based on generic/standard requirements of particular industry or segment of people in the market then those are called Product Based Software.
Eg: Google Search Engine, www.gmail.com, www.youtube.com, www.webex.com etc

ii.              Project Based Software:
Whenever software developed based on particular organization or requirements then those are called Project Based Software.
Client, End User and Company
i.                  Client/Customer:
It is an organization or individual person who will provide requirements to develop the software.
E.g.
www.grafx-itsolutions.com -> client in “grafx-itsolutions” , it is an organization or single person.
                            Or
Who will buy the license to use software.
E.g. www.webex.com -> client is grafx-itsolutions

ii.              End User:
Who will use software in their business with real data.
E.g.: faculty and students who will use www.webex.com

iii.           Company:
It is an organization where software will be developed as per given requirements.
E.g.
www.webex.com -> It is “Cisco” company product.

Based on work there are two types of companies in IT Industry.
i.                  Product Based Company
ii.              Service Based Company
i.                  Product Based Company:
Company which will focus on their own products to develop.
E.g. Google, Microsoft, HP, Dell, CISCO etc.

ii.              Service Based Company:
Company which will develop individual projects for individual clients.
Eg: TCS, Infosys, Accenture etc.

Environment
Set of software and hardware configuration to perform particular activities by specific team.

There are four types of environments for a project.
i.                  Development Environment
ii.              Test Environment
iii.           User Acceptance Test Environment
iv.            Production Environment

i.                  Development Environment:
It is also called producer environment.  In this environment development team will write the program in order to develop the application as per requirements.

ii.              Test Environment:
It is also called staging environment.  Where separate testing involved to validate application as per client requirements and expectations.

iii.           User Acceptance Test Environment:
Where client team involved in order to confirm application is acceptable or not.



iv.            Production Environment:
Where end user will uses S/W with real date in their business.

Based on usage S/W can be categorized into two types.
1.   System Software
2.   Application Software
1 . System Software
        It is also called BIOS(Base Input/Output System).  Which are used to provide interface among the system components(i.e. system booting)
Eg: Device drivers, operating system like windows, unix, linux, solaris etc.
2.Application Software
        Also called as Front-End application which are used to perform particular business activities in a system.  Whereas Front-End used to manipulate data into back end.

Why do you prefer Software Testing(Job)?
·       It is Technology independent
·       Consistency in Job activities(some roles and responsibilities)
·       Scope to learn different domains
·       Basically I am passionate about Testing activities where it more suitable for my thinking abilities to break the system/to find loop holes in a system.
Common problems in SDLC:
1.   Poor Requirements:
When initial requirements are not clear or incomplete to develop application
2.   Unrealistic schedule:
If too much of work crammed in a too little time
3.   Inadequate Testing: (incomplete testing)
In present scenario it is difficult to estimate how much testing sufficient to validate application
4.   Dynamic changes in Requirements:
When client continuously sending changes in the requirements
5.   Miscommunication:
Lack of communication among the associated project members


Q: When do defects will arise while developing application?
Due to human mistakes while developing application
There is a possibility to defects will arise
i.                  Mistakes in Coding àcoding defects
ii.              Mistakes in Design à Design Defects
iii.           Wrong Requirements àWrong project/Product
Note:
Correct Requirementsà Design to meet Requirements àCoding to meet Design àRight project/product

Q: do you think due to TE’s mistake defects will arise while developing application?
No, due to TE mistake existing defects are not identified (i.e. defects leakage)

Defect Repair cost w. r. to SDLC phases:
In general defect repair cost is estimated using following formula
(no. of persons*no. of hours)
DRC=-----------------------------------------*cost per person-hr
                (no. of defects resolved)

SDLC phases
Defect Repair Cost
Requirements
0% of cost
Design
10% of Cost
Coding
30% of Cost
Testing
50% of Cost
Maintenance
100% of cost

Q:  when do you think testing activities should start in development process of s/w? why?
Testing activities should start early stages with development activities
Early stages identified defects will take less cost to resolve those defects compare to later stages identified defects



Quality Management:
It is a process of preventing defects while developing s/w to ensure there are no defects in final product
QM is divided into 2 parts
i.                  Quality Assurance (QA)
ii.              Quality Control (QC)
i.                  Quality Assurance:
QA team will define development process of S/w in order to prevent defects
QA team will involve throughout life cycle to monitor and measure strength of development process, if any weakness identified then they provide suggestion to improve strength of development process

ii.              Quality Control (QC)
QC team will involve after product is built in order to identify any defects in it, if any defects are identified then make sure those defects should be resolved before deliver application to the client
Q: Explain difference between QA and QC
QA
QC
It is a process oriented
It is product oriented(i.e. Out comes)
It involve throughout life cycle
It involve after product is built
**it is a defects preventive approach
**it is defects detective approach
Auditing, Reviews are the QA activities
s/w testing is an example of QC activity

SDLC Methodologies/Models:
In general high level management team (i.e. QA Team) will decide which model we need to follow to develop application
Based on need of client and complexity of requirements we can adopt any one of the following SDLC model to develop application
Note:
Case study: {to select SDLC model}
1. need of client:
        a. Budget:
                client-1: normal cost
                client-2: low cost

        b. Time:{Actual duration for a project 12 months}
                Client-3: wait up to 12 months
        Client-4: wait up to 8 months then expecting some partial release
                Client-5: Wait up to 3 months then expecting whole system
2. complexity of requirements:
        Scenarios:
        Scenario-1:
                small project with clear requirements
        Scenario-2:
                big project with clear requirements
        Scenario-3:
                incomplete requirements
        Scenario-4:
                Risk in Requirements
        Scenario-5:
                Dynamic changes in requirements



PHP Notes

The Characteristics of PHP:- ----------------------------------- 1.PHP is a high level programming language. 2.It is a server-side scrip...