0% found this document useful (0 votes)
3 views2 pages

Java Programs 3

Uploaded by

Nikhil Wankhede
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views2 pages

Java Programs 3

Uploaded by

Nikhil Wankhede
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Sample output : After removing the duplicate elements

the program should return 4 as the new length of the


array.

Q.5. Write a Java method to check whether a string is a


valid password or not.

Password rules:
A password must have at least six characters.
A password must have at least 1 uppercase and 1
lowercase character.
A password must contain at least two digits.

Test case 1
Input :
Java
Output :
A password must have at least six characters.

Test case 2
Input :
java1rocks12
Output :
A password must have at least 1 uppercase and 1
lowercase character.
Test case 3
Input :
JavaRocks1
Output :
A password must have at least two digits.
Test case 4
Input :
JavaRocks12
Output :
Your password has been created.

Hint:- Create 3 separate boolean methods(static) that will


return true or false based on the logic and conditions,
Put these methods in a separate class and main method in
a separate class and from main method create object and
than call these methods
Take the password from user and based on user’s entered
password display him the appropriate message according
to out test cases.

You might also like