Solved by Expert Tutors
Solved by Expert Tutors
Question

Create public functional interface Validate with a method : public boolean validateName(String name);


Create public class ValidateUtility with the below methods :


public static Validate validateEmployeeName() -

The lambda expression for the validateName method must return true if the name is valid and return false if the name is invalid. 

In this case, the name is valid if it contains alphabets and space and it should contain minimum 5 characters and maximum 20 characters.

public static Validate validateProductName() -

The lambda expression for the validateName method must return true if the name is valid and return false if the name is invalid. 

In this case, the name is valid if the first character is an alphabet followed by 5 digits.

Write the main method in ValidateUtility class.

       - Get the value for employee name and product name. 

       - Invoke the validateEmployeeName method

       - Capture the object of Validate returned by the static method.

       - Invoke the validateName method for the employee name received as input from the user.

       - Display the result as shown in sample output. 

       - Next, invoke the validateProductName method

       - Capture the object of Validate returned by the static method.

       - Invoke the validateName method for the product name received as input from the user.

       - Display the result as shown in sample output. 

Note : Implement all the static methods mentioned above using lambda expression. Don't create object for the interface using new keyword.

Sample Input 1 :

Pinky Rose

A8546

Sample Output 1 :

Employee name is valid

Product name is invalid


Sample Input 2 :

[email protected]

X82456

Sample Output 1 :

Employee name is invalid

Product name is valid



Explanation for code Template:

Validate.java:-

public interface Validate{

  //write the abstract method 

  public boolean validateName(String name);

}


ValidateUtility.java:-

import java.util.*;

public class ValidateUtility

{

  public static void main(String args[])

  {

    //fill code here

  }

  public static Validate validateEmployeeName() 

  {

    //fill code here

  }

  public static Validate validateProductName() 

  {

    //fill code here

  }

}

Step-by-step answer

rem ipsum dolor sit

icitur laoreet. N


o

ipsum dolor sit amet, consectetur adipiscing

o


llentesque dapibus efficitur

o

molestie consequat, ultrices ac magna.

facilisis. Pellentesque dapibus efficitur

nec

llentesque dapibus efficitur laoreet. Nam ris

, ultrices ac magna. Fusce dui le

ur laoreet. Nam risus ante, dapibus a molestie

molestie consequat, ultrices ac mag

a molestie co

molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel

a molestie co

s ante, dapibus

a molestie co

fficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultri

a molestie co

ng elit. Nam lacinia pulvinar to

m ipsum dolor sit amet, consectetur ad

or nec facilisis. Pellentesque dapibus efficit

risus ante, dapibus a molestie consequa

a molestie co

facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante

a molestie co

s ante, dapibus

a molestie co

ce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliq

a molestie co

ec f

entesque dapibus efficitur laoreet. Nam risus ante, d

nec

molestie consequat, ultr

ac, dictum vitae odio. Donec al

ipiscing elit. Nam lacinia pulvinar tortor nec fa

sus ante, dapibus a molestie consequa

molestie consequat, ul

s ante, dapibus a molestie

ng elit. Nam lacinia pulvinar tortor nec f

nec facilisis. Pellentesque dapibus

sque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices

facilisis. Pellentesque dapibus efficitur la

m risus ante, dapibus a mole

ia pulvinar tortor n

usce dui

o. Donec aliquet.

ec f

ec facilisis. Pellentesque dapibus efficitur laoreet

nec

molestie consequat, ultr

ac, dictum vitae odio. Donec al

icitur laoreet. Nam risus ante, d

sus ante, dapibus a molestie consequa

, dictum vitae odio. Donec aliquet

ur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac m

sus ante, dapibus a molestie consequa

molestie consequat, ul

congue vel laoreet ac, dictum vitae odio

nec facilisis. Pellentesque dapibus

risus ante, dapibus a molestie consequat, ultrices ac

facilisis. Pellentesque dapibus efficitur la

m risus ante, dapibus a mole

ia pulvinar tortor n

usce dui

o. Donec aliquet.

ec f

o

acinia pulvi

Lambdajava.PNG

Lambdajava.PNG
r

Subscribe to view the full answer

Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors.

  • -

    Study Documents

    Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access.

    Browse Documents
  • -

    Question & Answers

    Get one-on-one homework help from our expert tutors—available online 24/7. Ask your own questions or browse existing Q&A threads. Satisfaction guaranteed!

    Ask a Question