Amazon Interview Question for Quality Assurance Engineers


Team: Amazon Wireless
Country: India
Interview Type: Written Test




Comment hidden because of low score. Click to expand.
2
of 2 vote

we have to give test data not code
1. Valid Test data
email@domain.com
"email"@domain.com
email@subdomain.domain.com
email1-email2@domain.com
email1.email2@domain.com
email@121.121.121.121
email@[121.121.121.121]
123451331@domain.com

2.Invalid Test Data
email //no @
email@domain@domain.com //more than 1 @not allowed
email"xyz"zmn@domain.com //double quotes in mid of local part of an email not allowed
email.@domain.com //trailing dot in local part not allowed
.email@domain.com
email@domain..com //double dot not allowed
email@1234.1223.1233.13233 //invalid ip adress
email.domain.com //@ missing
email@domain //no top level domain

- Anonymus July 28, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<string.h>
#include<ctype.h>
int checkmail(char a[],int n);
void main()
{
char a[20];
int n,result;
clrscr();
cout<<"Enter an email id:";
cin.getline(a,20);
n=strlen(a);
result=checkmail(a,n);
if(result==0)
cout<<"It is an invalid e-mail id";
else
cout<<"It is a valid e-mail id";
getch();
}

int checkmail(char a[],int n)
{
int ka=0;
for(int i=0;i<n;i++)
{
if(isalpha(a[i]))
continue;
if((a[i]=='@') && (i!=0) && isalpha(a[i+1]))
{
ka=i;
if(a[n-3]=='.' && a[n-2]=='c' && a[n-1]=='o' && a[n]=='m')
return 1;
}
if((a[i]=='@') && i==0)
return 0;
}
if(i==n && ka==0)
return 0;
}

- harmanjeet kaur July 26, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<string.h>
#include<ctype.h>
int checkmail(char a[],int n);
void main()
{
char a[20];
int n,result;
clrscr();
cout<<"Enter an email id:";
cin.getline(a,20);
n=strlen(a);
result=checkmail(a,n);
if(result==0)
cout<<"It is an invalid e-mail id";
else
cout<<"It is a valid e-mail id";
getch();
}

int checkmail(char a[],int n)
{
int ka=0;
for(int i=0;i<n;i++)
{
if(isalpha(a[i]))
continue;
if((a[i]=='@') && (i!=0) && isalpha(a[i+1]))
{
ka=i;
if(a[n-3]=='.' && a[n-2]=='c' && a[n-1]=='o' && a[n]=='m')
return 1;
}
if((a[i]=='@') && i==0)
return 0;
}
if(i==n && ka==0)
return 0;
}

- Harmanjeet kaur July 26, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Scanner scanner = new Scanner(System.in);
		String line = scanner.nextLine();
		Pattern pattern =  Pattern.compile("[A-Z0-9._]+@[A-Z0-9.-]+\\.[A-Z]{2,4}");
		Matcher matcher = pattern.matcher(line.toUpperCase());
		if(matcher.matches()){
			System.out.println("E-mail validated!");
		}
		else{
			System.out.println("Invalid email!!");
		}

- T July 26, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

we have to give test data not code
1. Valid Test data
email@domain.com
"email"@domain.com
email@subdomain.domain.com
email1-email2@domain.com
email1.email2@domain.com
email@121.121.121.121
email@[121.121.121.121]
123451331@domain.com

2.Invalid Test Data
email //no @
email@domain@domain.com //more than 1 @not allowed
email"xyz"zmn@domain.com //double quotes in mid of local part of an email not allowed
email.@domain.com //trailing dot in local part not allowed
.email@domain.com
email@domain..com //double dot not allowed
email@1234.1223.1233.13233 //invalid ip adress
email.domain.com //@ missing
email@domain //no top level domain

- Anonymous July 28, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

we have to give test data not code
1. Valid Test data
email@domain.com
"email"@domain.com
email@subdomain.domain.com
email1-email2@domain.com
email1.email2@domain.com
email@121.121.121.121
email@[121.121.121.121]
123451331@domain.com

2.Invalid Test Data
email //no @
email@domain@domain.com //more than 1 @not allowed
email"xyz"zmn@domain.com //double quotes in mid of local part of an email not allowed
email.@domain.com //trailing dot in local part not allowed
.email@domain.com
email@domain..com //double dot not allowed
email@1234.1223.1233.13233 //invalid ip adress
email.domain.com //@ missing
email@domain //no top level domain

- Anonymous July 28, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

we have to give test data not code 1. Valid Test data email@domain.com "email"@domain.com email@subdomain.domain.com email1-email2@domain.com email1.email2@domain.com email@121.121.121.121 email@[121.121.121.121] 123451331@domain.com 2.Invalid Test Data email //no @ email@domain@domain.com //more than 1 @not allowed email"xyz"zmn@domain.com //double quotes in mid of local part of an email not allowed email.@domain.com //trailing dot in local part not allowed .email@domain.com email@domain..com //double dot not allowed email@1234.1223.1233.13233 //invalid ip adress email.domain.com //@ missing email@domain //no top level domain

- Anonymous July 28, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

import re
import random
import string

def testEmail():
    # some useful constraints on valid email addresses:
    # name@provider.domain or name1st.name2nd@subdomain.domain
    # name, name1st, name2nd may contain letters, numbers, and {-,_,+}
    # provider and (sub)domain names contain only letters and
    # their lengths are restricted to 20 letters
    # len(email) <= 254, regex, char and lengths distributions can be adjusted to make data look more natural

    email = '[\w|\-|\+]+(?:\.(?:[\w|\-|\+]+))?@\w+(?:\.\w{1,20}){1,10}'
    rx = re.compile(email)

    # i) create some invalid entries
    print('Test for invalid entries: ')
    for _ in list(range(10)):
        length = random.SystemRandom().randint(1,254)
        email = ''.join(random.SystemRandom().choice(string.printable) for _ in range(length))
        # invalidate if by chance correct
        if email.endswith(r'@\w+(?:\.\w{1,20}){1,10}'):
            email = email.replace('@', '')
        if rx.match(email) is not None:
            print('\tfalse positive: ', email)
        else:
            print('\ttrue negative: ', email)

    # ii) create valid entries
    print('Test for valid entries: ')
    for _ in list(range(10)):
        min_len = 5 # @t.tk
        max_len = 254
        state = 0
        email = ''
        while (state != 3):
            if state == 0: # choose 1st usr name
                l1 = random.SystemRandom().randint(1, max_len-min_len)
                email = ''.join(random.SystemRandom().choice(string.ascii_letters + string.digits + '-_+') for _ in range(l1))
                # prefix 2 ?
                l2 = 0
                if random.SystemRandom().randint(1, 100) % 2 == 0:
                    l2 = random.SystemRandom().randint(1, max_len-min_len-l1)
                    email += '.'
                    email += ''.join(random.SystemRandom().choice(string.ascii_letters + string.digits + '-_+') for _ in range(l2))
                state = 1
            if state == 1: # add provider
                l3 = min(20, int(random.SystemRandom().weibullvariate(5, 1))+2)
                email += '@' + ''.join(random.SystemRandom().choice(string.ascii_letters) for _ in range(l3))
                state = 2
            if state == 2 and len(email) < max_len: # add domain and optional subdomains
                l4 = min(10, int(random.SystemRandom().weibullvariate(5, 1))+2)
                email += '.' + ''.join(random.SystemRandom().choice(string.ascii_letters) for _ in range(l4))
                if random.SystemRandom().randint(1, 100) % 2 == 0: # exit state 2 with prob. 0.5
                    state = 3
            if len(email) > max_len:
                state = 0 # repeat

        # test whether email really matches
        if rx.match(email.lower()) is not None:
            print('\ttrue positive: ', email)
        else:
            print('\tfalse negative: ', email)


if __name__ == '__main__':
    testEmail()

- Marie Hoffmann July 30, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

import re
import random
import string

def testEmail():
    # some useful constraints on valid email addresses:
    # name@provider.domain or name1st.name2nd@subdomain.domain
    # name, name1st, name2nd may contain letters, numbers, and {-,_,+}
    # provider and (sub)domain names contain only letters and
    # their lengths are restricted to 20 letters
    # len(email) <= 254, regex, char, and lengths distribution can be adjusted to make data more natural

    email = '[\w|\-|\+]+(?:\.(?:[\w|\-|\+]+))?@\w+(?:\.\w{1,20}){1,10}'
    rx = re.compile(email)

    # i) create some invalid entries
    print('Test for invalid entries: ')
    for _ in list(range(10)):
        length = random.SystemRandom().randint(1,254)
        email = ''.join(random.SystemRandom().choice(string.printable) for _ in range(length))
        # invalidate if by chance correct
        if email.endswith(r'@\w+(?:\.\w{1,20}){1,10}'):
            email = email.replace('@', '')
        if rx.match(email) is not None:
            print('\tfalse positive: ', email)
        else:
            print('\ttrue negative: ', email)

    # ii) create valid entries
    print('Test for valid entries: ')
    for _ in list(range(10)):
        min_len = 5 # @t.tk
        max_len = 254
        state = 0
        email = ''
        while (state != 3):
            if state == 0: # choose 1st usr name
                l1 = random.SystemRandom().randint(1, max_len-min_len)
                email = ''.join(random.SystemRandom().choice(string.ascii_letters + string.digits + '-_+') for _ in range(l1))
                # prefix 2 ?
                l2 = 0
                if random.SystemRandom().randint(1, 100) % 2 == 0:
                    l2 = random.SystemRandom().randint(1, max_len-min_len-l1)
                    email += '.'
                    email += ''.join(random.SystemRandom().choice(string.ascii_letters + string.digits + '-_+') for _ in range(l2))
                state = 1
            if state == 1: # add provider
                l3 = min(20, int(random.SystemRandom().weibullvariate(5, 1))+2)
                email += '@' + ''.join(random.SystemRandom().choice(string.ascii_letters) for _ in range(l3))
                state = 2
            if state == 2 and len(email) < max_len: # add domain and optional subdomains
                l4 = min(10, int(random.SystemRandom().weibullvariate(5, 1))+2)
                email += '.' + ''.join(random.SystemRandom().choice(string.ascii_letters) for _ in range(l4))
                if random.SystemRandom().randint(1, 100) % 2 == 0: # exit state 2 with prob. 0.5
                    state = 3
            if len(email) > max_len:
                state = 0 # repeat

        # test whether email really matches
        if rx.match(email.lower()) is not None:
            print('\ttrue positive: ', email)
        else:
            print('\tfalse negative: ', email)


if __name__ == '__main__':
    testEmail()

- ozymandiaz147@googlemail.com July 30, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Test data to check email id field( textbox)
1.Enter a blank data- empty text field
2.Valid data format of an email id. abc@mail.com, abc@mail.in(spaces,alphabets,numbers, special symbols etc)
3.Invalid format of an email id. @$#@mail.in , "hello"$gmail.com
4.One or more values in same field.
For all conditions ,check proper error messages are generated.

- kalpana August 25, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 1 vote

public class TestEmailFormat {
private static final Pattern emailPattern = Pattern.compile("[\\w\\.]+@[\\w\\.]+.com");
public void main(String[] args) {
  if(args.length == 0) {
      System.out.println("Please provide one or more strings to validate");
      return;
  }
  for(String input:args) {
	if(emailPattern.matches(input)) {
		System.out.println(input + "has valid email syntax");
	} else {
		System.out.println(input + "is not a valid email address");
	}
   }
}
}

- N G Sundarasekaran July 26, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 1 vote

#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<string.h>
#include<ctype.h>
int checkmail(char a[],int n);
void main()
{
char a[20];
int n,result;
clrscr();
cout<<"Enter an email id:";
cin.getline(a,20);
n=strlen(a);
result=checkmail(a,n);
if(result==0)
cout<<"It is an invalid e-mail id";
else
cout<<"It is a valid e-mail id";
getch();
}

int checkmail(char a[],int n)
{
int ka=0;
for(int i=0;i<n;i++)
{
if(isalpha(a[i]))
continue;
if((a[i]=='@') && (i!=0) && isalpha(a[i+1]))
{
ka=i;
if(a[n-3]=='.' && a[n-2]=='c' && a[n-1]=='o' && a[n]=='m')
return 1;
}
if((a[i]=='@') && i==0)
return 0;
}
if(i==n && ka==0)
return 0;
}

- harmanjeet kaur July 26, 2015 | Flag Reply


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More